CLEANUP: move dump db file saving stuff into fpdb.pyw

This commit is contained in:
steffen123 2010-07-17 05:11:09 +02:00
parent 71108cdc9b
commit 139dfbafb5
2 changed files with 10 additions and 9 deletions

View File

@ -294,19 +294,16 @@ class Database:
self.connection.rollback() # make sure any locks taken so far are released self.connection.rollback() # make sure any locks taken so far are released
#end def __init__ #end def __init__
def dumpDatabase(self, filename): def dumpDatabase(self):
dumpFile = open(filename, 'w')
result="Database dump version " + str(DB_VERSION)+"\n\n" result="Database dump version " + str(DB_VERSION)+"\n\n"
tables=self.cursor.execute(self.sql.query['list_tables']) tables=self.cursor.execute(self.sql.query['list_tables'])
tables=self.cursor.fetchall() tables=self.cursor.fetchall()
dumpFile.write(result)
for table in tables: for table in tables:
table=table[0] table=table[0]
print "table:", table print "table:", table
result="###################\nTable "+table+"\n###################\n" result+="###################\nTable "+table+"\n###################\n"
rows=self.cursor.execute(self.sql.query['get'+table]) rows=self.cursor.execute(self.sql.query['get'+table])
rows=self.cursor.fetchall() rows=self.cursor.fetchall()
columnNames=self.cursor.description columnNames=self.cursor.description
@ -318,8 +315,7 @@ class Database:
result+=(" "+columnNames[columnNumber][0]+"="+str(row[columnNumber])+"\n") result+=(" "+columnNames[columnNumber][0]+"="+str(row[columnNumber])+"\n")
result+="\n" result+="\n"
result+="\n" result+="\n"
dumpFile.write(result) return result
dumpFile.close()
#end def dumpDatabase #end def dumpDatabase
# could be used by hud to change hud style # could be used by hud to change hud style

View File

@ -490,7 +490,12 @@ class fpdb:
#end def storeNewHudStatConfig #end def storeNewHudStatConfig
def dia_dump_db(self, widget, data=None): def dia_dump_db(self, widget, data=None):
self.db.dumpDatabase("database-dump.sql") filename = "database-dump.sql"
result = self.db.dumpDatabase()
dumpFile = open(filename, 'w')
dumpFile.write(result)
dumpFile.close()
#end def dia_database_stats #end def dia_database_stats
def dia_licensing(self, widget, data=None): def dia_licensing(self, widget, data=None):