2 years ago
how can I connect my project with PostgreSQL on this platform, I can’t understand, my Python code is asynchronous and when I add PostgreSQL to my project on Railway, I have 'asyncpg' in requirements.txt, but when I run it, an error occurs that requires 'psycopg2 '. How can I solve this problem?
5 Replies
2 years ago
In the Postgres service variables replace the DATABASE_URL variable with postgresql+asyncpg://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_TCP_PROXY_DOMAIN}}:${{RAILWAY_TCP_PROXY_PORT}}/${{PGDATABASE}}
And then reference it in your apps service like this DATABASE_URL=${{Postgres.DATABASE_URL}} and use the DATABASE_URL environment variable in your code.
Status changed to Solved Railway • over 1 year ago
2 years ago
Thank You!
2 years ago
Yeah! Thank you again!