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:
parent
b27b697ec6
commit
47f27cf31f
|
@ -244,6 +244,24 @@ class fpdb:
|
||||||
self.release_global_lock()
|
self.release_global_lock()
|
||||||
#end def dia_recreate_tables
|
#end def dia_recreate_tables
|
||||||
|
|
||||||
|
def dia_recreate_hudcache(self, widget, data=None):
|
||||||
|
if self.obtain_global_lock():
|
||||||
|
try:
|
||||||
|
dia_confirm = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING, buttons=(gtk.BUTTONS_YES_NO), message_format="Confirm recreating HUD cache")
|
||||||
|
diastring = "Please confirm that you want to re-create the HUD cache."
|
||||||
|
dia_confirm.format_secondary_text(diastring)
|
||||||
|
|
||||||
|
response = dia_confirm.run()
|
||||||
|
dia_confirm.destroy()
|
||||||
|
if response == gtk.RESPONSE_YES:
|
||||||
|
self.db.rebuild_hudcache()
|
||||||
|
elif response == gtk.REPSONSE_NO:
|
||||||
|
print 'User cancelled rebuilding hud cache'
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
self.release_global_lock()
|
||||||
|
|
||||||
|
|
||||||
def dia_regression_test(self, widget, data=None):
|
def dia_regression_test(self, widget, data=None):
|
||||||
print "todo: implement dia_regression_test"
|
print "todo: implement dia_regression_test"
|
||||||
self.obtain_global_lock()
|
self.obtain_global_lock()
|
||||||
|
@ -306,6 +324,7 @@ class fpdb:
|
||||||
<menuitem action="createdb"/>
|
<menuitem action="createdb"/>
|
||||||
<menuitem action="createuser"/>
|
<menuitem action="createuser"/>
|
||||||
<menuitem action="createtabs"/>
|
<menuitem action="createtabs"/>
|
||||||
|
<menuitem action="rebuildhudcache"/>
|
||||||
<menuitem action="stats"/>
|
<menuitem action="stats"/>
|
||||||
<menuitem action="sessions"/>
|
<menuitem action="sessions"/>
|
||||||
</menu>
|
</menu>
|
||||||
|
@ -344,6 +363,7 @@ class fpdb:
|
||||||
('createdb', None, 'Create or Delete _Database (todo)', None, 'Create or Delete Database', self.dia_create_del_database),
|
('createdb', None, 'Create or Delete _Database (todo)', None, 'Create or Delete Database', self.dia_create_del_database),
|
||||||
('createuser', None, 'Create or Delete _User (todo)', None, 'Create or Delete User', self.dia_create_del_user),
|
('createuser', None, 'Create or Delete _User (todo)', None, 'Create or Delete User', self.dia_create_del_user),
|
||||||
('createtabs', None, 'Create or Recreate _Tables', None, 'Create or Recreate Tables ', self.dia_recreate_tables),
|
('createtabs', None, 'Create or Recreate _Tables', None, 'Create or Recreate Tables ', self.dia_recreate_tables),
|
||||||
|
('rebuildhudcache', None, 'Rebuild HUD Cache', None, 'Rebuild HUD Cache', self.dia_recreate_hudcache),
|
||||||
('stats', None, '_Statistics (todo)', None, 'View Database Statistics', self.dia_database_stats),
|
('stats', None, '_Statistics (todo)', None, 'View Database Statistics', self.dia_database_stats),
|
||||||
('sessions', None, 'Sessions', None, 'View Sessions', self.dia_database_sessions),
|
('sessions', None, 'Sessions', None, 'View Sessions', self.dia_database_sessions),
|
||||||
('help', None, '_Help'),
|
('help', None, '_Help'),
|
||||||
|
|
|
@ -356,6 +356,10 @@ class fpdb_db:
|
||||||
"""Drop some indexes/foreign keys to prepare for bulk import.
|
"""Drop some indexes/foreign keys to prepare for bulk import.
|
||||||
Currently keeping the standalone indexes as needed to import quickly"""
|
Currently keeping the standalone indexes as needed to import quickly"""
|
||||||
stime = time()
|
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:
|
if self.backend == self.PGSQL:
|
||||||
self.db.set_isolation_level(0) # allow table/index operations to work
|
self.db.set_isolation_level(0) # allow table/index operations to work
|
||||||
for fk in self.foreignKeys[self.backend]:
|
for fk in self.foreignKeys[self.backend]:
|
||||||
|
@ -445,6 +449,12 @@ class fpdb_db:
|
||||||
def afterBulkImport(self):
|
def afterBulkImport(self):
|
||||||
"""Re-create any dropped indexes/foreign keys after bulk import"""
|
"""Re-create any dropped indexes/foreign keys after bulk import"""
|
||||||
stime = time()
|
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:
|
if self.backend == self.PGSQL:
|
||||||
self.db.set_isolation_level(0) # allow table/index operations to work
|
self.db.set_isolation_level(0) # allow table/index operations to work
|
||||||
for fk in self.foreignKeys[self.backend]:
|
for fk in self.foreignKeys[self.backend]:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user