Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db_url_config does not handle all postgres urls the same #268

Closed
sww314 opened this issue Aug 3, 2020 · 1 comment
Closed

db_url_config does not handle all postgres urls the same #268

sww314 opened this issue Aug 3, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@sww314
Copy link
Contributor

sww314 commented Aug 3, 2020

In particular, if you are trying to use a Cloud SQL Connection string and use POSTGIS as the engine it sets the database name as the host name.

If you are running on Google Cloud Run and want to connect to Google Cloud SQL instance with postgis, this will fail.

In [11]: POSTGRES = "postgres://user:password@//cloudsql/project-1234:us-central1:instance/dbname"                              

In [12]: POSTGIS = "postgis://user:password@//cloudsql/project-1234:us-central1:instance/dbname"                                

In [13]: Env.db_url_config(POSTGIS)                                                                                             
Out[13]: 
{'NAME': '/cloudsql/project-1234:us-central1:instance/dbname',
 'USER': 'user',
 'PASSWORD': 'password',
 'HOST': '',
 'PORT': '',
 'ENGINE': 'django.contrib.gis.db.backends.postgis'}

In [14]: Env.db_url_config(POSTGRES)                                                                                            
Out[14]: 
{'NAME': 'dbname',
 'USER': 'user',
 'PASSWORD': 'password',
 'HOST': '/cloudsql/project-1234:us-central1:instance',
 'PORT': '',
 'ENGINE': 'django.db.backends.postgresql'}

@sergeyklay
Copy link
Collaborator

This is resolved in develop branch. Thank you for the report, and for helping us make django-environ better. And I am sorry about the delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants