Skip to content

Commit

Permalink
Fixed reset_db with psycopg3 (same patch like for drop_test_database)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jann Haber committed May 27, 2023
1 parent 4fc31cb commit 1cdb258
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions django_extensions/management/commands/reset_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def handle(self, *args, **options):
else:
import psycopg2 as Database # NOQA

conn_params = {'database': 'template1'}
conn_params = {'dbname': 'template1'}
if user:
conn_params['user'] = user
if password:
Expand All @@ -159,7 +159,10 @@ def handle(self, *args, **options):
conn_params['port'] = database_port

connection = Database.connect(**conn_params)
connection.set_isolation_level(0) # autocommit false
if has_psycopg3:
connection.autocommit = True
else:
connection.set_isolation_level(0) # autocommit false
cursor = connection.cursor()

if options['close_sessions']:
Expand Down

0 comments on commit 1cdb258

Please sign in to comment.