I cannot connect to postgre
Closed this issue · 2 comments
thisAKcode commented
Hey
I played with fastapi as per this video: https://www.youtube.com/watch?v=d_ugoWsvGLI
I repeated all steps but at the end I got an error about authentication.
We can take it on next call otherwise here is the way to reproduce it:
cd C:\fastapi_project1\app
uvicorn main:app --reload
the error is:
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: FATAL: password authentication failed for user "postgres"
thisAKcode commented
it is solved. Sorry I didn't make a real PR , but just merged it to master. it was related to engine configuration
I just needed to put my overlycomplicated pw into following:
import urllib.parse
urllib.parse.quote_plus("my_pw_included_tricky_to_encode_chars")
bbelderbos commented
OK this all works, but remember to load DB url from the environment, see https://pybit.es/articles/how-to-handle-environment-variables-in-python/