Skip to content

Commit

Permalink
disable foreign key on clean up
Browse files Browse the repository at this point in the history
Signed-off-by: Soldy <[email protected]>
  • Loading branch information
Soldy committed Sep 1, 2024
1 parent 4fdf51c commit 370c7f4
Showing 1 changed file with 49 additions and 11 deletions.
60 changes: 49 additions & 11 deletions src/openPanthera/mariadblib.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,36 @@ def _destroyBuildScript(self):

def _cleanBuildScript(self, type_:str, file_name_:str):
self._cur.execute(
"UPDATE panthera_migration SET destroyed = ? WHERE destroyed = ? AND type = ? AND file = ?",
(
int( time.time() ),
0,
type_,
file_name_
)
(
"UPDATE panthera_migration "+
"SET destroyed = ? WHERE "+
"destroyed = ? AND type = ? AND file = ?"
),(
int( time.time() ),
0,
type_,
file_name_
)
)
self._conn.commit()
def _foreignDisable(self):
try:
self._cur.execute(
"SET GLOBAL FOREIGN_KEY_CHECKS=0;"
)
self._conn.commit()
self._p("Foreign check disabled")
except Exception:
self._p("Foreign check cannot disabled")
def _foreignEnable(self):
try:
self._cur.execute(
"SET GLOBAL FOREIGN_KEY_CHECKS=1;"
)
self._conn.commit()
self._p("Foreign check enabled")
except Exception:
self._p("Foreign check cannot enabled")
def _showStatus(self, type_:str):
lista = []
self._cur.execute(
Expand All @@ -177,11 +198,13 @@ def _showStatus(self, type_:str):
lista.append(Name)
return lista
def _dropIfExists(self, type_:str, name_:str):
self._foreignDisable()
self._cur.execute(
"DROP "+type_+" `"+name_+"`;"
)
self._p("Delete "+type_+" "+name_)
self._conn.commit()
self._foreignEnable()
def _showProcedures(self):
for (
Name
Expand Down Expand Up @@ -236,10 +259,25 @@ def _listTables(self):
lista.append(Name)
return lista
def _showTables(self):
for (
Name
) in self._listTables():
self._p(f"{Name}")
for (
Name
) in self._listTables():
self._p(f"{Name}")
# def _jsonTable(self, name_:str):
# lista = []
# self._cur.execute(
# "DESC "+name_
# )
# for (
# Field,
# Type,
# Null,
# Key,
# Default,
# Extra
# ) in self._listTables():
# self._p(f"{Name}")
# self._dropIfExists("TABLES", Name)
def _deleteAllTables(self):
for (
Name
Expand Down

0 comments on commit 370c7f4

Please sign in to comment.