On 3/5/08, Michael Schlenker <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> i have some queries using IN, e.g.
>
> SELECT * FROM t WHERE uuid IN (...);
>
> (uuid is a blob field storing uuids btw.)
>
> Is there a way to use bind variables for this, e.g. something like this:
> (python wrapper, this example doesn't work)
> cursor.execute("SELECT * FROM t WHERE uuid IN (?)",([uuid1,uuid2],))
>
> Or would i have to create a dynamic query with appropriate number of bind
> variables myself and have to pay the price of reparsing each time?
>
> # like this
> values = [uuid1,uuid2]
> binders = ",".join("?"*len(values))
> cursor.execute("SELECT * FROM t WHERE uuid IN (%s)" % binders, values)
>
> I also had some rather complex piece of SQL from "The Art of SQL", which
> took a string and dissected it in place with subqueries and a join to a
> pivot table, but wondered if there was an easier way to do it?
>
..
Using Perl, I usually do
SELECT cols FROM table WHERE col IN (?)
and then
$s = join "," @foo;
$sth->execute($s);
works fine for me.
--
Puneet Kishor http://punkish.eidesis.org/
Nelson Institute for Environmental Studies http://www.nelson.wisc.edu/
Open Source Geospatial Foundation (OSGeo) http://www.osgeo.org/
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users