Edgewall Software
Modify

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)

pysqlite2_r1970.patch (9.6 KB ) - added by Rede <redetin@…> 19 years ago.
Patch for pysqlite2 wrapper

Download all attachments as: .zip

Change History (7)

comment:1 by anonymous, 19 years ago

Summary: PySqLitePySqLite2

comment:2 by anonymous, 19 years ago

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).

comment:3 by Rede <redetin@…>, 19 years ago

Owner: changed from Jonas Borgström to anonymous
Status: newassigned

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 Christopher Lenz, 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 Rede <redetin@…>, 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.

by Rede <redetin@…>, 19 years ago

Attachment: pysqlite2_r1970.patch added

Patch for pysqlite2 wrapper

comment:6 by Christopher Lenz, 19 years ago

Priority: normalhigh
Resolution: fixed
Status: assignedclosed

PySQLite 2 support has now been implemented.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain anonymous.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from anonymous to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.