summaryrefslogtreecommitdiff
path: root/db.py
diff options
context:
space:
mode:
authorSylvain <syt@logilab.fr>2006-09-19 11:38:16 +0200
committerSylvain <syt@logilab.fr>2006-09-19 11:38:16 +0200
commitc60bed25b0d53ab9f604f353bb6f97e90a499847 (patch)
treeb462c0b0a1c7d62dcc1fd06e0dec7a41c6634238 /db.py
parentcf88be2a16e01a12785ad0cfc9ba5cc69a143409 (diff)
downloadlogilab-common-c60bed25b0d53ab9f604f353bb6f97e90a499847.tar.gz
* db:
- fixed bug when querying boolean on sqlite using python's bool type - added "drop_on_commit" argument to create_temporary_table on db helper - added missing implementation of executemany on pysqlite2 wrapper to support pyargs correctly like execute * optik_ext: fixed "named" type option to support csv values and to return a dictionary
Diffstat (limited to 'db.py')
-rw-r--r--db.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/db.py b/db.py
index d27145d..75ffbd7 100644
--- a/db.py
+++ b/db.py
@@ -313,6 +313,10 @@ class _PySqlite2Adapter(DBAPIAdapter):
else:
self.__class__.__bases__[0].execute(self, sql)
+ def executemany(self, sql, kwargss):
+ sql = re.sub(r'%\(([^\)]+)\)s', r':\1', sql)
+ self.__class__.__bases__[0].executemany(self, sql, kwargss)
+
class PySqlite2CnxWrapper:
def __init__(self, cnx):
self._cnx = cnx
@@ -402,9 +406,10 @@ INSERT INTO %s VALUES (0);''' % (seq_name, seq_name)
return ('UPDATE %s SET last=last+1;' % seq_name,
'SELECT last FROM %s;' % seq_name)
- def sql_temporary_table(self, table_name, table_schema):
+ def sql_temporary_table(self, table_name, table_schema,
+ drop_on_commit=True):
return "CREATE TEMPORARY TABLE %s (%s);" % (table_name,
- table_schema)
+ table_schema)
def increment_sequence(self, cursor, seq_name):
for sql in self.sqls_increment_sequence(seq_name):
@@ -429,9 +434,13 @@ class _PGAdvFuncHelper(_GenericAdvFuncHelper):
def sqls_increment_sequence(self, seq_name):
return ("SELECT nextval('%s');" % seq_name,)
- def sql_temporary_table(self, table_name, table_schema):
+ def sql_temporary_table(self, table_name, table_schema,
+ drop_on_commit=True):
+ if not drop_on_commit:
+ return "CREATE TEMPORARY TABLE %s (%s);" % (table_name,
+ table_schema)
return "CREATE TEMPORARY TABLE %s (%s) ON COMMIT DROP;" % (table_name,
- table_schema)
+ table_schema)
def sql_current_date(self):
return "'TODAY'"