@@ -144,15 +144,36 @@ def _destroyBuildScript(self):
144
144
145
145
def _cleanBuildScript (self , type_ :str , file_name_ :str ):
146
146
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
+ )
154
157
)
155
158
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" )
156
177
def _showStatus (self , type_ :str ):
157
178
lista = []
158
179
self ._cur .execute (
@@ -177,11 +198,13 @@ def _showStatus(self, type_:str):
177
198
lista .append (Name )
178
199
return lista
179
200
def _dropIfExists (self , type_ :str , name_ :str ):
201
+ self ._foreignDisable ()
180
202
self ._cur .execute (
181
203
"DROP " + type_ + " `" + name_ + "`;"
182
204
)
183
205
self ._p ("Delete " + type_ + " " + name_ )
184
206
self ._conn .commit ()
207
+ self ._foreignEnable ()
185
208
def _showProcedures (self ):
186
209
for (
187
210
Name
@@ -236,10 +259,25 @@ def _listTables(self):
236
259
lista .append (Name )
237
260
return lista
238
261
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)
243
281
def _deleteAllTables (self ):
244
282
for (
245
283
Name
0 commit comments