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
#end def __init__
def dumpDatabase(self, filename):
dumpFile = open(filename, 'w')
def dumpDatabase(self):
result="Database dump version " + str(DB_VERSION)+"\n\n"
tables=self.cursor.execute(self.sql.query['list_tables'])
tables=self.cursor.fetchall()
dumpFile.write(result)
for table in tables:
table=table[0]
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.fetchall()
columnNames=self.cursor.description
@ -318,8 +315,7 @@ class Database:
result+=(" "+columnNames[columnNumber][0]+"="+str(row[columnNumber])+"\n")
result+="\n"
result+="\n"
dumpFile.write(result)
dumpFile.close()
return result
#end def dumpDatabase
# could be used by hud to change hud style

View File

@ -490,7 +490,12 @@ class fpdb:
#end def storeNewHudStatConfig
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
def dia_licensing(self, widget, data=None):