Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

sqlalchemy root password with @ , show error (2003, "Can't connect to MySQL server on '16535@localhost' ([Errno 11003] [duplicate]

Ask Question
engine = sqlalchemy.create_engine('mysql+pymysql://root:Sakura%s@16535@localhost:3306/'+coin[x]) 

error

sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on '16535@localhost' ([Errno 11003] getaddrinfo failed)")

Any help? Thank you

Important

Percent encoding must be used for reserved characters in the elements of the URI-like string. For example, if you specify a string that includes the @ character, the character must be replaced by %40. If you include a zone ID in an IPv6 address, the % character used as the separator must be replaced with %25.

So the quick answer is to replace the @ symbol with %40. In general you can encode a string in a URI-safe manner as follows, working in Python:

import urllib.parse
encoded = urllib.parse.quote_plus(unencoded)