When I tried to connect database from Python, my password contains special character say for example: 123@789. My Connection fails because of this.
I make connection to the database as follows:
engine = sqlalchemy.create_engine('sybase+pyodbc://user:123@789@Database')
URL-encode the @ in the password. Adapted from https://docs.sqlalchemy.org/en/13/core/engines.html,
import urllib.parse
password = urllib.parse.quote_plus("123@789") # '123%40456'
engine = sqlalchemy.create_engine(f'sybase+pyodbc://user:{password}@Database')
Alternatively, let sqlalchemy generate the URL for you using sqlalchemy.engine.url.URL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With