@@ -144,15 +144,36 @@ def _destroyBuildScript(self):
144144
145145 def _cleanBuildScript (self , type_ :str , file_name_ :str ):
146146 self ._cur .execute (
147- "UPDATE panthera_migration SET destroyed = ? WHERE destroyed = ? AND type = ? AND file = ?" ,
148- (
149- int ( time .time () ),
150- 0 ,
151- type_ ,
152- file_name_
153- )
147+ (
148+ "UPDATE panthera_migration " +
149+ "SET destroyed = ? WHERE " +
150+ "destroyed = ? AND type = ? AND file = ?"
151+ ),(
152+ int ( time .time () ),
153+ 0 ,
154+ type_ ,
155+ file_name_
156+ )
154157 )
155158 self ._conn .commit ()
159+ def _foreignDisable (self ):
160+ try :
161+ self ._cur .execute (
162+ "SET GLOBAL FOREIGN_KEY_CHECKS=0;"
163+ )
164+ self ._conn .commit ()
165+ self ._p ("Foreign check disabled" )
166+ except Exception :
167+ self ._p ("Foreign check cannot disabled" )
168+ def _foreignEnable (self ):
169+ try :
170+ self ._cur .execute (
171+ "SET GLOBAL FOREIGN_KEY_CHECKS=1;"
172+ )
173+ self ._conn .commit ()
174+ self ._p ("Foreign check enabled" )
175+ except Exception :
176+ self ._p ("Foreign check cannot enabled" )
156177 def _showStatus (self , type_ :str ):
157178 lista = []
158179 self ._cur .execute (
@@ -177,11 +198,13 @@ def _showStatus(self, type_:str):
177198 lista .append (Name )
178199 return lista
179200 def _dropIfExists (self , type_ :str , name_ :str ):
201+ self ._foreignDisable ()
180202 self ._cur .execute (
181203 "DROP " + type_ + " `" + name_ + "`;"
182204 )
183205 self ._p ("Delete " + type_ + " " + name_ )
184206 self ._conn .commit ()
207+ self ._foreignEnable ()
185208 def _showProcedures (self ):
186209 for (
187210 Name
@@ -236,10 +259,25 @@ def _listTables(self):
236259 lista .append (Name )
237260 return lista
238261 def _showTables (self ):
239- for (
240- Name
241- ) in self ._listTables ():
242- self ._p (f"{ Name } " )
262+ for (
263+ Name
264+ ) in self ._listTables ():
265+ self ._p (f"{ Name } " )
266+ # def _jsonTable(self, name_:str):
267+ # lista = []
268+ # self._cur.execute(
269+ # "DESC "+name_
270+ # )
271+ # for (
272+ # Field,
273+ # Type,
274+ # Null,
275+ # Key,
276+ # Default,
277+ # Extra
278+ # ) in self._listTables():
279+ # self._p(f"{Name}")
280+ # self._dropIfExists("TABLES", Name)
243281 def _deleteAllTables (self ):
244282 for (
245283 Name
0 commit comments