[CalendarServer-changes] [1658]
CalendarServer/branches/users/cdaboo/digestdb-fix-1654/twistedcaldav
/sql.py
source_changes at macosforge.org
source_changes at macosforge.org
Thu Jul 12 12:25:22 PDT 2007
Revision: 1658
http://trac.macosforge.org/projects/calendarserver/changeset/1658
Author: cdaboo at apple.com
Date: 2007-07-12 12:25:22 -0700 (Thu, 12 Jul 2007)
Log Message:
-----------
Add an auto-commit option for more efficient DB usage when doing one-off statements that do not require
transaction support.
Add an option to close any open database, so we can recyle the connection in the case of a recurring
failures.
Modified Paths:
--------------
CalendarServer/branches/users/cdaboo/digestdb-fix-1654/twistedcaldav/sql.py
Modified: CalendarServer/branches/users/cdaboo/digestdb-fix-1654/twistedcaldav/sql.py
===================================================================
--- CalendarServer/branches/users/cdaboo/digestdb-fix-1654/twistedcaldav/sql.py 2007-07-12 16:10:59 UTC (rev 1657)
+++ CalendarServer/branches/users/cdaboo/digestdb-fix-1654/twistedcaldav/sql.py 2007-07-12 19:25:22 UTC (rev 1658)
@@ -38,13 +38,16 @@
A generic SQL database.
"""
- def __init__(self, dbpath):
+ def __init__(self, dbpath, autocommit=False):
"""
@param dbpath: the path where the db file is stored.
@type dbpath: str
+ @param autocommit: C{True} if auto-commit mode is desired, C{False} otherwise
+ @type autocommit: bool
"""
self.dbpath = dbpath
+ self.autocommit = autocommit
def _db_version(self):
"""
@@ -65,7 +68,10 @@
"""
if not hasattr(self, "_db_connection"):
db_filename = self.dbpath
- self._db_connection = sqlite.connect(db_filename)
+ if self.autocommit:
+ self._db_connection = sqlite.connect(db_filename, isolation_level=None)
+ else:
+ self._db_connection = sqlite.connect(db_filename)
#
# Set up the schema
@@ -179,6 +185,10 @@
"""
pass
+ def _db_close(self):
+ if hasattr(self, "_db_connection"):
+ del self._db_connection
+
def _db_values_for_sql(self, sql, *query_params):
"""
Execute an SQL query and obtain the resulting values.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070712/ee969163/attachment.html
More information about the calendarserver-changes
mailing list