Changeset 2741 for pykota/trunk/pykota/storages/mysqlstorage.py
- Timestamp:
- 02/21/06 18:15:40 (18 years ago)
- Files:
-
- 1 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) :