-1

code

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

error

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

Any help? Thank you

snakecharmerb
  • 47,570
  • 11
  • 100
  • 153
Json Prime
  • 180
  • 1
  • 10

1 Answers1

2

From the MySQL docs:

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)
Paddy Alton
  • 1,855
  • 1
  • 7
  • 11