R
Railway10mo ago
Girish

Sharing postgress DB between 2 services

How do i share the same PostgressSQL Db instance between 2 services in railway.
Solution:
open up the raw editor in both of the services variables tabs, and then paste in this ```env PGDATABASE=${{Postgres.PGDATABASE}} PGUSER=${{Postgres.PGUSER}} PGPASSWORD=${{Postgres.PGPASSWORD}}...
Jump to solution
9 Replies
Percy
Percy10mo ago
Project ID: N/A
Girish
Girish10mo ago
N/A
Brody
Brody10mo ago
is postgres in the same project?
Girish
Girish10mo ago
yes i will show u screenshot
Girish
Girish10mo ago
No description
Girish
Girish10mo ago
i want mails service and web service to share the same Db instance i have added all the db user/password/url variables to both web and mails services
Solution
Brody
Brody10mo ago
open up the raw editor in both of the services variables tabs, and then paste in this
PGDATABASE=${{Postgres.PGDATABASE}}
PGUSER=${{Postgres.PGUSER}}
PGPASSWORD=${{Postgres.PGPASSWORD}}
PGHOST=${{Postgres.PGHOST}}
PGPORT=${{Postgres.PGPORT}}
PGDATABASE=${{Postgres.PGDATABASE}}
PGUSER=${{Postgres.PGUSER}}
PGPASSWORD=${{Postgres.PGPASSWORD}}
PGHOST=${{Postgres.PGHOST}}
PGPORT=${{Postgres.PGPORT}}
then in your code you connect to the database as shown here https://github.com/railwayapp-templates/django/blob/main/mysite/settings.py#L81-L90
Girish
Girish10mo ago
Thank you so much , my issues are resolved! really appreciate your inputs
Brody
Brody10mo ago
no problem!
Want results from more Discord servers?
Add your server