mirror of https://github.com/OWASP/Nettacker.git
fixed the create database part of postgresql.py (#1072)
This commit is contained in:
parent
10c95512e6
commit
4fd743a15d
|
|
@ -10,7 +10,6 @@ def postgres_create_database():
|
|||
when using postgres database, this is the function that is used to
|
||||
create the database for the first time when you the nettacker run module.
|
||||
"""
|
||||
|
||||
try:
|
||||
engine = create_engine(
|
||||
"postgresql+psycopg2://{username}:{password}@{host}:{port}/{name}".format(
|
||||
|
|
@ -21,15 +20,14 @@ def postgres_create_database():
|
|||
except OperationalError:
|
||||
# if the database does not exist
|
||||
engine = create_engine(
|
||||
"postgresql+psycopg2://{username}:{password}@{host}:{port}/{name}".format(
|
||||
"postgresql+psycopg2://{username}:{password}@{host}:{port}/postgres".format(
|
||||
**Config.db.as_dict()
|
||||
)
|
||||
)
|
||||
conn = engine.connect()
|
||||
conn.execute("commit")
|
||||
conn = conn.execution_options(isolation_level="AUTOCOMMIT")
|
||||
conn.execute(text(f"CREATE DATABASE {Config.db.name}"))
|
||||
conn.close()
|
||||
|
||||
engine = create_engine(
|
||||
"postgresql+psycopg2://{username}:{password}@{host}:{port}/{name}".format(
|
||||
**Config.db.as_dict()
|
||||
|
|
|
|||
Loading…
Reference in New Issue