Skip to content
Snippets Groups Projects
Commit 315640f6 authored by grollicus's avatar grollicus
Browse files

made username lookup work with psycopg 3

parent 54aed294
No related branches found
No related tags found
No related merge requests found
......@@ -2,11 +2,18 @@ from types import MethodType
from django.test.runner import DiscoverRunner
from django.db import connections
def prepare_database(self):
self.connect()
try:
username = self.connection.get_dsn_parameters()['user']
except AttributeError: # psycopg has moved this method
username = self.connection.info.get_parameters()['user']
self.connection.cursor().execute(f"""
CREATE SCHEMA rc3schema AUTHORIZATION {self.connection.get_dsn_parameters()["user"]};
GRANT ALL ON SCHEMA rc3schema TO {self.connection.get_dsn_parameters()["user"]};
CREATE SCHEMA rc3schema AUTHORIZATION {username};
GRANT ALL ON SCHEMA rc3schema TO {username};
""")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment