mirror of https://github.com/OWASP/Nettacker.git
Disconnect Handling to SQL
This commit is contained in:
parent
af2c05bdb8
commit
f93f8613a3
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#ignore IDE settings
|
#ignore IDE settings
|
||||||
*.idea*
|
*.idea*
|
||||||
|
*.vscode*
|
||||||
|
|
||||||
#setup
|
#setup
|
||||||
build/*
|
build/*
|
||||||
|
|
|
||||||
|
|
@ -43,25 +43,22 @@ def db_inputs(connection_type):
|
||||||
|
|
||||||
def create_connection():
|
def create_connection():
|
||||||
"""
|
"""
|
||||||
a function to create connections to db, it retries 100 times if connection returned an error
|
a function to create connections to db with pessimistic approach
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
connection if success otherwise False
|
connection if success otherwise False
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
for _ in range(0, 100):
|
|
||||||
try:
|
try:
|
||||||
db_engine = create_engine(
|
db_engine = create_engine(
|
||||||
db_inputs(DB),
|
db_inputs(DB),
|
||||||
connect_args={
|
connect_args={
|
||||||
'check_same_thread': False
|
'check_same_thread': False
|
||||||
}
|
},
|
||||||
|
pool_pre_ping=True
|
||||||
)
|
)
|
||||||
Session = sessionmaker(bind=db_engine)
|
Session = sessionmaker(bind=db_engine)
|
||||||
session = Session()
|
session = Session()
|
||||||
return session
|
return session
|
||||||
except Exception:
|
|
||||||
time.sleep(0.1)
|
|
||||||
except Exception:
|
except Exception:
|
||||||
warn(messages("database_connect_fail"))
|
warn(messages("database_connect_fail"))
|
||||||
return False
|
return False
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ texttable==1.6.7
|
||||||
PySocks==1.7.1 # library_name=socks # module name is not equal to socks name; this is required to be checked on startup
|
PySocks==1.7.1 # library_name=socks # module name is not equal to socks name; this is required to be checked on startup
|
||||||
pyOpenSSL==23.2.0 # library_name=OpenSSL
|
pyOpenSSL==23.2.0 # library_name=OpenSSL
|
||||||
flask==2.3.2
|
flask==2.3.2
|
||||||
SQLAlchemy>=1.3.0 # library_name=sqlalchemy
|
SQLAlchemy>=1.4.43 # library_name=sqlalchemy
|
||||||
py3DNS==3.2.1 # library_name=DNS
|
py3DNS==3.2.1 # library_name=DNS
|
||||||
numpy==1.24.3
|
numpy==1.24.3
|
||||||
terminable_thread==0.7.1
|
terminable_thread==0.7.1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue