PostgreSQL Connection Trouble

cube
TRIAL

a year 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?

Solved

5 Replies

a year 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


cube
TRIAL

a year ago

Thank You!


a year ago

Let me know if that works for you!


cube
TRIAL

a year ago

Yeah! Thank you again!


a year ago

No problem!