# ValueError: Port could not be cast to integer value when connecting to Qovery Postgres from Python
## The problem
Created a Postgres database in Qovery, copied the db_url from the dashboard, and used it with SQLAlchemy and the databases library in Python. Every connection attempt raised ValueError: Port could not be cast to integer value, pointing at part of the password. The auto-generated passwords contain special characters like $, ?, @, and =, which break URL parsing, so urllib treated a chunk of the password as the port. Recreating the database produced a new password with the same problem.
## The verified fix
The password in the connection URL has to be percent-encoded before you hand the URL to your driver, because Qovery generates passwords with URL-significant characters like @, $, ?, and =. Use urllib.parse.quote on the password with safe='' and rebuild the URL, or just quote the password segment in place. The reporter confirmed this fixed it, and noted the same issue hits Flask, FastAPI, or any Python framework parsing the URL, not just Django.
Source: https://github.com/Qovery/engine/issues/457