<!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.&nbsp; The problem was to use 
pysqlite to search (in memory) a large number (&gt;10,000) of string items 
containing the substring q (and to do it continuosly with different q's).&nbsp; 
The solution was to incase the substring q with % ie. '%q%'.&nbsp; The 
performance is excellent.&nbsp; </FONT></DIV>
<DIV><FONT color=#000080></FONT>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT color=#000080>Dinesh</FONT></DIV>
<DIV><FONT color=#000080></FONT>&nbsp;</DIV>
<DIV><FONT 
color=#000080>..............................................................</FONT></DIV>
<DIV>Date: Fri, 11 Apr 2008 13:20:12 +0100<BR>From: Tim Golden &lt;<A 
href="mailto:mail@timgolden.me.uk">mail@timgolden.me.uk</A>&gt;<BR>Subject: Re: 
[Tutor] SQLite LIKE question<BR>Cc: <A 
href="mailto:tutor@python.org">tutor@python.org</A><BR>Message-ID: &lt;<A 
href="mailto:47FF577C.7090904@timgolden.me.uk">47FF577C.7090904@timgolden.me.uk</A>&gt;<BR>Content-Type: 
text/plain; charset=ISO-8859-1; format=flowed<BR><BR>Dinesh B Vadhia 
wrote:<BR>&gt; Okay, I've got this now:<BR>&gt; <BR>&gt;&gt; con = 
sqlite3.connect(":memory:")<BR>&gt;&gt; cur = con.cursor()<BR>&gt;&gt; 
cur.execute("""CREATE TABLE db.table(col.a integer, col.b text)""")<BR>&gt;&gt; 
con.executemany("""INSERT INTO db.table(col.a, col.b) VALUES (?, ?)""", 
m)<BR>&gt;&gt; con.commit()<BR>&gt; <BR>&gt;&gt; for row in 
con.execute("""SELECT col.a, col.b FROM 
db.table"""):<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 
row<BR>&gt;&gt; # when run, all rows are printed correctly but as unicode 
strings<BR>&gt;&gt; q = "dog"<BR>&gt;&gt; for row in con.execute("""SELECT col.b 
FROM db.table WHERE col.b LIKE ? LIMIT 25""", 
q):<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print row<BR>&gt; 
<BR>&gt; .. And, I get the following error:<BR>&gt; <BR>&gt; Traceback (most 
recent call last):<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp; for row in 
con.execute("SELECT col.b FROM db.table WHERE col.b LIKE ? LIMIT 25", 
q):<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp; 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>&nbsp;</DIV></BODY></HTML>