Changeset 3308
- Timestamp:
- 01/30/08 21:48:29 (16 years ago)
- Location:
- pykota/trunk/pykota/storages
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/mysqlstorage.py
r3294 r3308 22 22 23 23 """This module defines a class to access to a MySQL database backend.""" 24 25 import time26 24 27 25 from pykota.errors import PyKotaStorageError … … 73 71 def beginTransaction(self) : 74 72 """Starts a transaction.""" 75 self.before = time.time()76 73 self.cursor.execute("BEGIN;") 77 74 self.tool.logdebug("Transaction begins...") … … 80 77 """Commits a transaction.""" 81 78 self.database.commit() 82 after = time.time()83 79 self.tool.logdebug("Transaction committed.") 84 #self.tool.logdebug("Transaction duration : %.4f seconds" % (after - self.before))85 80 86 81 def rollbackTransaction(self) : 87 82 """Rollbacks a transaction.""" 88 83 self.database.rollback() 89 after = time.time()90 84 self.tool.logdebug("Transaction aborted.") 91 #self.tool.logdebug("Transaction duration : %.4f seconds" % (after - self.before))92 85 93 86 def doRawSearch(self, query) : … … 97 90 query += ';' 98 91 try : 99 before = time.time()100 92 self.querydebug("QUERY : %s" % query) 101 93 self.cursor.execute(query) 102 94 except self.database.Error, msg : 103 raise PyKotaStorageError, str(msg)95 raise PyKotaStorageError, repr(msg) 104 96 else : 105 97 # This returns a list of lists. Integers are returned as longs. 106 98 result = self.cursor.fetchall() 107 after = time.time()108 #self.tool.logdebug("Query Duration : %.4f seconds" % (after - before))109 99 return result 110 100 … … 136 126 query += ';' 137 127 try : 138 before = time.time()139 128 self.querydebug("QUERY : %s" % query) 140 129 self.cursor.execute(query) 141 130 except self.database.Error, msg : 142 131 self.tool.logdebug("Query failed : %s" % repr(msg)) 143 raise PyKotaStorageError, str(msg) 144 else : 145 after = time.time() 146 #self.tool.logdebug("Query Duration : %.4f seconds" % (after - before)) 132 raise PyKotaStorageError, repr(msg) 147 133 148 134 def doQuote(self, field) : -
pykota/trunk/pykota/storages/pgstorage.py
r3294 r3308 23 23 """This module defines a class to access to a PostgreSQL database backend.""" 24 24 25 import time26 25 from types import StringType 27 26 … … 76 75 def beginTransaction(self) : 77 76 """Starts a transaction.""" 78 self.before = time.time()79 77 self.database.query("BEGIN;") 80 78 self.tool.logdebug("Transaction begins...") … … 83 81 """Commits a transaction.""" 84 82 self.database.query("COMMIT;") 85 after = time.time()86 83 self.tool.logdebug("Transaction committed.") 87 #self.tool.logdebug("Transaction duration : %.4f seconds" % (after - self.before))88 84 89 85 def rollbackTransaction(self) : 90 86 """Rollbacks a transaction.""" 91 87 self.database.query("ROLLBACK;") 92 after = time.time()93 88 self.tool.logdebug("Transaction aborted.") 94 #self.tool.logdebug("Transaction duration : %.4f seconds" % (after - self.before))95 89 96 90 def doRawSearch(self, query) : … … 100 94 query += ';' 101 95 try : 102 before = time.time()103 96 self.querydebug("QUERY : %s" % query) 104 re sult =self.database.query(query)97 return self.database.query(query) 105 98 except PGError, msg : 106 raise PyKotaStorageError, str(msg) 107 else : 108 after = time.time() 109 #self.tool.logdebug("Query Duration : %.4f seconds" % (after - before)) 110 return result 99 raise PyKotaStorageError, repr(msg) 111 100 112 101 def doSearch(self, query) : … … 122 111 query += ';' 123 112 try : 124 before = time.time()125 113 self.querydebug("QUERY : %s" % query) 126 re sult =self.database.query(query)114 return self.database.query(query) 127 115 except PGError, msg : 128 116 self.tool.logdebug("Query failed : %s" % repr(msg)) 129 raise PyKotaStorageError, str(msg) 130 else : 131 after = time.time() 132 #self.tool.logdebug("Query Duration : %.4f seconds" % (after - before)) 133 return result 117 raise PyKotaStorageError, repr(msg) 134 118 135 119 def doQuote(self, field) : -
pykota/trunk/pykota/storages/sqlitestorage.py
r3294 r3308 22 22 23 23 """This module defines a class to access to a SQLite database backend.""" 24 25 import time26 24 27 25 from pykota.errors import PyKotaStorageError … … 57 55 def beginTransaction(self) : 58 56 """Starts a transaction.""" 59 self.before = time.time()60 57 self.cursor.execute("BEGIN;") 61 58 self.tool.logdebug("Transaction begins...") … … 64 61 """Commits a transaction.""" 65 62 self.cursor.execute("COMMIT;") 66 after = time.time()67 63 self.tool.logdebug("Transaction committed.") 68 #self.tool.logdebug("Transaction duration : %.4f seconds" % (after - self.before))69 64 70 65 def rollbackTransaction(self) : 71 66 """Rollbacks a transaction.""" 72 67 self.cursor.execute("ROLLBACK;") 73 after = time.time()74 68 self.tool.logdebug("Transaction aborted.") 75 #self.tool.logdebug("Transaction duration : %.4f seconds" % (after - self.before))76 69 77 70 def doRawSearch(self, query) : … … 81 74 query += ';' 82 75 try : 83 before = time.time()84 76 self.querydebug("QUERY : %s" % query) 85 77 self.cursor.execute(query) 86 78 except self.database.Error, msg : 87 raise PyKotaStorageError, str(msg)79 raise PyKotaStorageError, repr(msg) 88 80 else : 89 81 result = self.cursor.fetchall() 90 after = time.time()91 #self.tool.logdebug("Query Duration : %.4f seconds" % (after - before))92 82 return result 93 83 … … 118 108 query += ';' 119 109 try : 120 before = time.time()121 110 self.querydebug("QUERY : %s" % query) 122 111 self.cursor.execute(query) 123 112 except self.database.Error, msg : 124 113 self.tool.logdebug("Query failed : %s" % repr(msg)) 125 raise PyKotaStorageError, str(msg) 126 else : 127 after = time.time() 128 #self.tool.logdebug("Query Duration : %.4f seconds" % (after - before)) 114 raise PyKotaStorageError, repr(msg) 129 115 130 116 def doQuote(self, field) :