R
Railway11mo 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
Percy11mo ago
Project ID: N/A
Girish
GirishOP11mo ago
N/A
Brody
Brody11mo ago
is postgres in the same project?
Girish
GirishOP11mo ago
yes i will show u screenshot
Girish
GirishOP11mo ago
No description
Girish
GirishOP11mo 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
Brody11mo 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
GirishOP11mo ago
Thank you so much , my issues are resolved! really appreciate your inputs
Brody
Brody11mo ago
no problem!
Want results from more Discord servers?
Add your server