dabo Commit
Revision 6513
Date: 2011-03-31 01:47:58 -0700 (Thu, 31 Mar 2011)
Author: Jacekk
Trac: http://trac.dabodev.com/changeset/6513
Changed:
U trunk/dabo/db/dDataSet.py
U trunk/dabo/db/dbSQLite.py
Log:
Changed default Encoding to the backend declared one.
Diff:
Modified: trunk/dabo/db/dDataSet.py
===================================================================
--- trunk/dabo/db/dDataSet.py 2011-03-31 05:26:02 UTC (rev 6512)
+++ trunk/dabo/db/dDataSet.py 2011-03-31 08:47:58 UTC (rev 6513)
@@ -191,9 +191,9 @@
filtered = [rec for rec in self if fnc(rec[fld], expr)]
elif op in ("startswith", "beginswith"):
filtered = [rec for rec in self if
rec[fld].startswith(expr)]
- elif op =="endswith":
+ elif op == "endswith":
filtered = [rec for rec in self if
rec[fld].endswith(expr)]
- elif op =="contains":
+ elif op == "contains":
filtered = [rec for rec in self if expr in rec[fld]]
ret = self.__class__(filtered)
ret._sourceDataSet = self
@@ -352,9 +352,11 @@
if self._connection is None:
self._connection = sqlite.connect(":memory:",
-
detect_types=(sqlite.PARSE_DECLTYPES|sqlite.PARSE_COLNAMES),
+ detect_types=(sqlite.PARSE_DECLTYPES |
sqlite.PARSE_COLNAMES),
isolation_level="EXCLUSIVE")
- self._connection.text_factory = str
+ if not hasattr(self, "_encoding"):
+ self._encoding =
self._connection.execute("PRAGMA encoding"). \
+ fetchone()[0].lower()
if self._cursor is None:
self._cursor =
self._connection.cursor(factory=DictCursor)
@@ -377,7 +379,7 @@
# We have a table now with the necessary data. Run the query!
if params and not isinstance(params, tuple):
- params = (params, )
+ params = (params,)
self._cursor.execute(sqlExpr, params)
# et = time.clock()
Modified: trunk/dabo/db/dbSQLite.py
===================================================================
--- trunk/dabo/db/dbSQLite.py 2011-03-31 05:26:02 UTC (rev 6512)
+++ trunk/dabo/db/dbSQLite.py 2011-03-31 08:47:58 UTC (rev 6513)
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
import sys
import os
import re
@@ -72,13 +72,10 @@
# Need to specify "isolation_level=None" to have transactions
working correctly.
self._connection = self.dbapi.connect(pth,
factory=DictConnection, isolation_level=None)
-
- # Non-utf8-encoded bytestrings could be in the database, and
Dabo will try various encodings
- # to deal with it. So tell sqlite not to decode with utf-8, but
to just return the bytes:
- # The statement above is true only conditionally, so we must
pay attention to this.
- if not self._alreadyCorrectedFieldTypes:
- self._connection.text_factory = str
self._connection.connectInfo = connectInfo
+ if not hasattr(self, "_encoding"):
+ self._encoding = self._connection.execute("PRAGMA
encoding"). \
+ fetchone()["encoding"].lower()
return self._connection
@@ -97,7 +94,7 @@
sl = "\\"
qt = "\'"
val = ustr(val)
- return qt + val.replace(sl, sl+sl).replace(qt, qt+qt) + qt
+ return qt + val.replace(sl, sl + sl).replace(qt, qt + qt) + qt
def beginTransaction(self, cursor):
@@ -194,7 +191,7 @@
# Adi J. Sieker pointed out that the 'pk' column of the
pragma command
# returns a value indicating whether the field is the
PK or not. This simplifies
# the routine over having to parse the CREATE TABLE
code.
- fields.append( (rec["name"], fldType, bool(rec['pk'])) )
+ fields.append((rec["name"], fldType, bool(rec['pk'])))
return tuple(fields)
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]