Opened 19 years ago
Closed 19 years ago
#1746 closed enhancement (fixed)
PySqLite2
Reported by: | anonymous | Owned by: | anonymous |
---|---|---|---|
Priority: | high | Milestone: | 0.9 |
Component: | general | Version: | devel |
Severity: | normal | Keywords: | database pysqlite pysqlite2 |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
with the new databasebackend, can't someone write a pysqlite2 connector?
According to the benchmarks it's around twice as fast
Attachments (1)
Change History (7)
comment:1 by , 19 years ago
Summary: | PySqLite → PySqLite2 |
---|
comment:2 by , 19 years ago
comment:3 by , 19 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
I made parameter formatting fix for cx_Oracle when I tried to use Oracle as Trac-backend. I will give it a try to make same for PySqlite2.
comment:4 by , 19 years ago
Gerhard Haering posted a "proof-of-concept" implementation of this to the PySQLite mailing list here. As the actual content of the message doesn't show in the pipermail archive, I'll copy it here:
Message:
Attached is proof-of-concept for code that allows you to use the pyformat style with pysqlite 2.0. It needs fleshing out for executemany, and maybe for named parameters (%(foo)s, %(bar)s).
In my opinion, something like this could be used to make TRAC compatible with pysqlite 2.
Maybe it is a useful starting point for somebody.
Attachment:
from pysqlite2 import dbapi2 as sqlite class PyFormatConnection(sqlite.Connection): def cursor(self): return sqlite.Connection.cursor(self, PyFormatCursor) class PyFormatCursor(sqlite.Cursor): def execute(self, sql, args=None): if args: qmarks = ["?"] * len(args) sql = sql % tuple(qmarks) sqlite.Cursor.execute(self, sql, args) else: sqlite.Cursor.execute(self, sql) con = sqlite.connect(":memory:", factory=PyFormatConnection) cur = con.cursor() cur.execute("create table test(a, b, c)") cur.execute("insert into test(a, b, c) values (%s, %s, %s)", ('asdf', 4, 5.2)) cur.execute("select a, b, c from test where c <> %s", (4.27,)) print cur.fetchone() cur.close() con.close()
comment:5 by , 19 years ago
Well above code is almost identical to mine, (but it's even better than mine), so I'll adapt my code to look more like above and post a patch.
comment:6 by , 19 years ago
Priority: | normal → high |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
PySQLite 2 support has now been implemented.
The problem is that pysqlite2 doesn't use the same formatting as every other DB 2.0 API on the face of the earth. It uses ? and :name style interploation (which is built into SQLite) rather than the standard %s and %(name)s formatting. If someone were to step up to the plate and implemente this for pysqlite2, then it would literally be 20 minutes of work to set up pysqlite2 (I already did it for Argon before I realized the interpolation syntax was different).