MySQL request in Python
DONT! String format your sql queries, but let the cursor do it for you.

As @Gareth Rees said, this is not secure!


c.execute("SELECT accounts_info_uid "
          "FROM auth_info WHERE login='{}' ".format(login))



As taken from the docs, this would be the proper way to execute statements with sql:

cursor.execute("SELECT accounts_info_uid FROM auth_info WHERE login = %s", login)

You could use a context manager over the connection

Using a context manager would improve the readability, see PEP343

There are some resource out there how to implement such a thing
Make the login a separate function
I think it can be optimized in one SQL request?

Yes, but without the database itself it is hard to test, a github repo or some more information would help.

However you could improve on your google-fu, Simply typing "mysql join 3 tables" would have given you the answer you are looking for.

https://stackoverflow.com/questions/3709560/joining-three-tables-using-mysql