Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Paste
P1173
(An Untitled Masterwork)
Active
Public
Actions
Authored by
douardda
on Sep 22 2021, 6:15 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
ddouard (e) swh master … 2 ~/s/s/swh-web cat swh/web/django_db_backend/base.py
from django.db.backends.postgresql.base import * # NOQA
from django.db.backends.postgresql.base import DatabaseWrapper as _DatabaseWrapper
# dirty hack to allow using a postgresql:// libpq connection URI as db name...
# This allows to define the connection arguments in a pg_service file, put
# the credential in the pgpass file, etc.
class DatabaseWrapper(_DatabaseWrapper):
def get_connection_params(self):
if self.settings_dict.get("NAME", "").startswith("postgresql://"):
return {"dsn": self.settings_dict["NAME"]}
return super().get_connection_params()
Event Timeline
douardda
created this paste.
Sep 22 2021, 6:15 PM
2021-09-22 18:15:15 (UTC+2)
Log In to Comment