[sqlalchemy] Oracle in clause limit

2010-02-12 Thread grach
Hello all,

I'm relatively new to SQLAlchemy - is there any elegant workaround
that SQLAlchemy provides for queries with in clause that contains more
than 1000 items?

I have, say, date, item, value table that I'd like to query for
arbitrary set of dates and items (date and item list is provided by
the user or generated by the program. (I'd like to avoid creating temp
tables with arguments and perfoming a join).

Many thanks,

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Oracle in clause limit

2010-02-12 Thread Alexander Grach
Thanks!



Michael Bayer mike...@zzzcomputing.com 
Sent by: sqlalchemy@googlegroups.com
02/12/2010 10:48 AM
Please respond to
sqlalchemy@googlegroups.com


To
sqlalchemy@googlegroups.com
cc

Subject
Re: [sqlalchemy] Oracle in clause limit






grach wrote:
 Hello all,

 I'm relatively new to SQLAlchemy - is there any elegant workaround
 that SQLAlchemy provides for queries with in clause that contains more
 than 1000 items?

 I have, say, date, item, value table that I'd like to query for
 arbitrary set of dates and items (date and item list is provided by
 the user or generated by the program. (I'd like to avoid creating temp
 tables with arguments and perfoming a join).

Since you don't want to use a subquery/temp table, there's no other option
except to iteratively execute N number of queries where N is (number of
items / 1000), and piece the results together.

it can be as easy as:

def select_lots_of_stuff(collection):
while collection:
items, collection = collection[:1000], collection[1000:]
for result in conn.execute(select.where(col.in_(items))):
yield result





 Many thanks,

 --
 You received this message because you are subscribed to the Google 
Groups
 sqlalchemy group.
 To post to this group, send email to sqlalch...@googlegroups.com.
 To unsubscribe from this group, send email to
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/sqlalchemy?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.




---
This communication may contain confidential and/or privileged information.
If you are not the intended recipient (or have received this communication
in error) please notify the sender immediately and destroy this
communication. Any unauthorized copying, disclosure or distribution of the
material in this communication is strictly forbidden.

Deutsche Bank does not render legal or tax advice, and the information
contained in this communication should not be regarded as such.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.