From 139dfbafb523b6783a6e6cb35025ed93ba7c7b1d Mon Sep 17 00:00:00 2001 From: steffen123 Date: Sat, 17 Jul 2010 05:11:09 +0200 Subject: [PATCH] CLEANUP: move dump db file saving stuff into fpdb.pyw --- pyfpdb/Database.py | 12 ++++-------- pyfpdb/fpdb.pyw | 7 ++++++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index cdfac060..d093edba 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -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 diff --git a/pyfpdb/fpdb.pyw b/pyfpdb/fpdb.pyw index b122d86e..295ed7d3 100755 --- a/pyfpdb/fpdb.pyw +++ b/pyfpdb/fpdb.pyw @@ -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):