fpdb.py: Add "Recreate HUD Cache" to Database menu

fpdb_db.py: Junk the dropping of indexes/FKs for MySQL INNODB in favor of just telling MySQL to ignore them.  Not sure if that works for other MySQL engines or other Database softwares.
This commit is contained in:
eblade
2009-07-27 17:28:06 -04:00
parent b27b697ec6
commit 47f27cf31f
2 changed files with 30 additions and 0 deletions
+10
View File
@@ -356,6 +356,10 @@ class fpdb_db:
"""Drop some indexes/foreign keys to prepare for bulk import.
Currently keeping the standalone indexes as needed to import quickly"""
stime = time()
if self.backend == self.MYSQL_INNODB:
self.cursor.execute("SET foreign_key_checks=0")
self.cursor.execute("SET autocommit=0")
return
if self.backend == self.PGSQL:
self.db.set_isolation_level(0) # allow table/index operations to work
for fk in self.foreignKeys[self.backend]:
@@ -445,6 +449,12 @@ class fpdb_db:
def afterBulkImport(self):
"""Re-create any dropped indexes/foreign keys after bulk import"""
stime = time()
if self.backend == self.MYSQL_INNODB:
self.cursor.execute("SET foreign_key_checks=1")
self.cursor.execute("SET autocommit=1")
return
if self.backend == self.PGSQL:
self.db.set_isolation_level(0) # allow table/index operations to work
for fk in self.foreignKeys[self.backend]: