Skip to content

Commit 4fd743a

Browse files
authored
fixed the create database part of postgresql.py (#1072)
1 parent 10c9551 commit 4fd743a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

nettacker/database/postgresql.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ def postgres_create_database():
1010
when using postgres database, this is the function that is used to
1111
create the database for the first time when you the nettacker run module.
1212
"""
13-
1413
try:
1514
engine = create_engine(
1615
"postgresql+psycopg2://{username}:{password}@{host}:{port}/{name}".format(
@@ -21,15 +20,14 @@ def postgres_create_database():
2120
except OperationalError:
2221
# if the database does not exist
2322
engine = create_engine(
24-
"postgresql+psycopg2://{username}:{password}@{host}:{port}/{name}".format(
23+
"postgresql+psycopg2://{username}:{password}@{host}:{port}/postgres".format(
2524
**Config.db.as_dict()
2625
)
2726
)
2827
conn = engine.connect()
29-
conn.execute("commit")
28+
conn = conn.execution_options(isolation_level="AUTOCOMMIT")
3029
conn.execute(text(f"CREATE DATABASE {Config.db.name}"))
3130
conn.close()
32-
3331
engine = create_engine(
3432
"postgresql+psycopg2://{username}:{password}@{host}:{port}/{name}".format(
3533
**Config.db.as_dict()

0 commit comments

Comments
 (0)