Michael Schlenker wrote: > > 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) >
If you are going to prepare the query each time, why not embed the values directly in the query string and avoid all the bind calls? There is no benefit to binding these values unless they are possibly user supplied strings that could be used for an SQL injection attack. If they are generated by your application it would be faster and simpler to skip that step. If you reuse sets of uuids in your application, then it might make sense to store the sets in a table and use a subquery to extract the set of interest at the time. create table uuid_sets( set_id integer, uuid text, primary key(set_id, uuid) ); select * from t where uuid in (select uuid from uuid_sets where set_id = ?); This query can be prepared once and reused. Now you just need to manage the uuid_sets table. This may be simpler if you reuse the sets often. HTH Dennis Cote _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users