- Timestamp:
- 02/21/06 18:15:40 (19 years ago)
- Location:
- pykota/trunk/pykota/storages
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/mysqlstorage.py
r2649 r2741 24 24 # 25 25 26 import time 27 26 28 from pykota.storage import PyKotaStorageError,BaseStorage,StorageObject,StorageUser,StorageGroup,StoragePrinter,StorageJob,StorageLastJob,StorageUserPQuota,StorageGroupPQuota 27 29 from pykota.storages.sql import SQLStorage … … 46 48 self.tool.logdebug("Trying to open database (host=%s, port=%s, dbname=%s, user=%s)..." % (host, port, dbname, user)) 47 49 self.database = MySQLdb.connect(host=host, port=port, db=dbname, user=user, passwd=passwd) 48 50 self.database.autocommit(1) 49 51 self.cursor = self.database.cursor() 50 52 self.closed = 0 … … 61 63 def beginTransaction(self) : 62 64 """Starts a transaction.""" 65 self.before = time.time() 63 66 self.cursor.execute("BEGIN;") 64 67 self.tool.logdebug("Transaction begins...") … … 67 70 """Commits a transaction.""" 68 71 self.database.commit() 72 after = time.time() 69 73 self.tool.logdebug("Transaction committed.") 74 self.tool.logdebug("Transaction duration : %.4f seconds" % (after - self.before)) 70 75 71 76 def rollbackTransaction(self) : 72 77 """Rollbacks a transaction.""" 73 78 self.database.rollback() 79 after = time.time() 74 80 self.tool.logdebug("Transaction aborted.") 81 self.tool.logdebug("Transaction duration : %.4f seconds" % (after - self.before)) 75 82 76 83 def doRawSearch(self, query) : … … 80 87 query += ';' 81 88 try : 89 before = time.time() 82 90 self.tool.logdebug("QUERY : %s" % query) 83 91 self.cursor.execute(query) … … 86 94 else : 87 95 # This returns a list of lists. Integers are returned as longs. 88 return self.cursor.fetchall() 96 result = self.cursor.fetchall() 97 after = time.time() 98 self.tool.logdebug("Query Duration : %.4f seconds" % (after - before)) 99 return result 89 100 90 101 def doSearch(self, query) : … … 115 126 query += ';' 116 127 try : 128 before = time.time() 117 129 self.tool.logdebug("QUERY : %s" % query) 118 130 self.cursor.execute(query) 119 131 except self.database.Error, msg : 120 132 raise PyKotaStorageError, str(msg) 133 else : 134 after = time.time() 135 self.tool.logdebug("Query Duration : %.4f seconds" % (after - before)) 121 136 122 137 def doQuote(self, field) : -
pykota/trunk/pykota/storages/pgstorage.py
r2622 r2741 23 23 # 24 24 25 import time 25 26 from types import StringType 26 27 … … 64 65 def beginTransaction(self) : 65 66 """Starts a transaction.""" 67 self.before = time.time() 66 68 self.database.query("BEGIN;") 67 69 self.tool.logdebug("Transaction begins...") … … 70 72 """Commits a transaction.""" 71 73 self.database.query("COMMIT;") 74 after = time.time() 72 75 self.tool.logdebug("Transaction committed.") 76 self.tool.logdebug("Transaction duration : %.4f seconds" % (after - self.before)) 73 77 74 78 def rollbackTransaction(self) : 75 79 """Rollbacks a transaction.""" 76 80 self.database.query("ROLLBACK;") 81 after = time.time() 77 82 self.tool.logdebug("Transaction aborted.") 83 self.tool.logdebug("Transaction duration : %.4f seconds" % (after - self.before)) 78 84 79 85 def doRawSearch(self, query) : … … 83 89 query += ';' 84 90 try : 91 before = time.time() 85 92 self.tool.logdebug("QUERY : %s" % query) 86 93 result = self.database.query(query) … … 88 95 raise PyKotaStorageError, str(msg) 89 96 else : 97 after = time.time() 98 self.tool.logdebug("Query Duration : %.4f seconds" % (after - before)) 90 99 return result 91 100 … … 102 111 query += ';' 103 112 try : 113 before = time.time() 104 114 self.tool.logdebug("QUERY : %s" % query) 105 115 result = self.database.query(query) … … 107 117 raise PyKotaStorageError, str(msg) 108 118 else : 119 after = time.time() 120 self.tool.logdebug("Query Duration : %.4f seconds" % (after - before)) 109 121 return result 110 122 -
pykota/trunk/pykota/storages/sqlitestorage.py
r2622 r2741 22 22 # 23 23 # 24 25 import time 24 26 25 27 from pykota.storage import PyKotaStorageError,BaseStorage,StorageObject,StorageUser,StorageGroup,StoragePrinter,StorageJob,StorageLastJob,StorageUserPQuota,StorageGroupPQuota … … 54 56 def beginTransaction(self) : 55 57 """Starts a transaction.""" 58 self.before = time.time() 56 59 self.cursor.execute("BEGIN;") 57 60 self.tool.logdebug("Transaction begins...") … … 60 63 """Commits a transaction.""" 61 64 self.cursor.execute("COMMIT;") 65 after = time.time() 62 66 self.tool.logdebug("Transaction committed.") 67 self.tool.logdebug("Transaction duration : %.4f seconds" % (after - self.before)) 63 68 64 69 def rollbackTransaction(self) : 65 70 """Rollbacks a transaction.""" 66 71 self.cursor.execute("ROLLBACK;") 72 after = time.time() 67 73 self.tool.logdebug("Transaction aborted.") 74 self.tool.logdebug("Transaction duration : %.4f seconds" % (after - self.before)) 68 75 69 76 def doRawSearch(self, query) : … … 73 80 query += ';' 74 81 try : 82 before = time.time() 75 83 self.tool.logdebug("QUERY : %s" % query) 76 84 self.cursor.execute(query) … … 78 86 raise PyKotaStorageError, str(msg) 79 87 else : 80 return self.cursor.fetchall() 88 result = self.cursor.fetchall() 89 after = time.time() 90 self.tool.logdebug("Query Duration : %.4f seconds" % (after - before)) 91 return result 81 92 82 93 def doSearch(self, query) : … … 106 117 query += ';' 107 118 try : 119 before = time.time() 108 120 self.tool.logdebug("QUERY : %s" % query) 109 121 self.cursor.execute(query) 110 122 except self.database.Error, msg : 111 123 raise PyKotaStorageError, str(msg) 124 else : 125 after = time.time() 126 self.tool.logdebug("Query Duration : %.4f seconds" % (after - before)) 112 127 113 128 def doQuote(self, field) :