<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16640" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT color=#000080>Guys, I got it to work. The problem was to use
pysqlite to search (in memory) a large number (>10,000) of string items
containing the substring q (and to do it continuosly with different q's).
The solution was to incase the substring q with % ie. '%q%'. The
performance is excellent. </FONT></DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080>The code is in my recent post (Subject: pysqlite and
functions) with a new problem ie. the code works as-is but not within a def
function.</FONT></DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080>Dinesh</FONT></DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT
color=#000080>..............................................................</FONT></DIV>
<DIV>Date: Fri, 11 Apr 2008 13:20:12 +0100<BR>From: Tim Golden <<A
href="mailto:mail@timgolden.me.uk">mail@timgolden.me.uk</A>><BR>Subject: Re:
[Tutor] SQLite LIKE question<BR>Cc: <A
href="mailto:tutor@python.org">tutor@python.org</A><BR>Message-ID: <<A
href="mailto:47FF577C.7090904@timgolden.me.uk">47FF577C.7090904@timgolden.me.uk</A>><BR>Content-Type:
text/plain; charset=ISO-8859-1; format=flowed<BR><BR>Dinesh B Vadhia
wrote:<BR>> Okay, I've got this now:<BR>> <BR>>> con =
sqlite3.connect(":memory:")<BR>>> cur = con.cursor()<BR>>>
cur.execute("""CREATE TABLE db.table(col.a integer, col.b text)""")<BR>>>
con.executemany("""INSERT INTO db.table(col.a, col.b) VALUES (?, ?)""",
m)<BR>>> con.commit()<BR>> <BR>>> for row in
con.execute("""SELECT col.a, col.b FROM
db.table"""):<BR>>> print
row<BR>>> # when run, all rows are printed correctly but as unicode
strings<BR>>> q = "dog"<BR>>> for row in con.execute("""SELECT col.b
FROM db.table WHERE col.b LIKE ? LIMIT 25""",
q):<BR>>> print row<BR>>
<BR>> .. And, I get the following error:<BR>> <BR>> Traceback (most
recent call last):<BR>> for row in
con.execute("SELECT col.b FROM db.table WHERE col.b LIKE ? LIMIT 25",
q):<BR>> ProgrammingError: Incorrect number of
bindings supplied. The current statement uses 1, and there are 3
supplied.<BR><BR>Whenever you see this in a dbapi context, you can bet your
socks<BR>that you're passing a single item (such as a string, q) rather
than<BR>a list or tuple of items. Try passing [q] as the second parameter<BR>to
that .execute function and see what happens!<BR><BR>TJG<BR></DIV>
<DIV><FONT color=#000080></FONT> </DIV></BODY></HTML>