you batch out the values to be used in the IN, then one of two choices: my preference is to run separate SELECT statements, using IN with each batch. If you really can't do that, you can combine the batches of IN groups with an OR: "x IN (batch1) OR x IN (batch2) ..."
keep in mind when you send enormous strings to your database, that places a burden on the query system. Oracle (which I assume you're using) also caches these queries. On Sep 5, 2014, at 2:30 AM, mando <[email protected]> wrote: > Hi to all, > > I wrote a method like this to reuse the code for many tables at the same > time[0] > > But, with more than 1000 records sqlite doesn't accepts the amount of id > inside .in_(id_list) > > How can I filter, split or can manage it? > > Thanks a lot and best regards, > Luca > > > [0] > def query_sort(self,id_list, op, to, tc, idn): > self.order_params = op #sorting parameters > self.type_order = to #asc or desc > self.table_class = tc #the name of the mapper class > self.id_name = idn #the name of the id > > filter_params = self.type_order + "(" + self.table_class + "." > + self.order_params[0] + ")" > for i in self.order_params[1:]: > filter_temp = self.type_order + "(" + self.table_class > + "." + i + ")" > > filter_params += ", "+ filter_temp > > Session = sessionmaker(bind=self.engine, autoflush=True, > autocommit=True) > session = Session() > > cmd_str = "session.query(" + self.table_class + ").filter(" + > self.table_class + "." + self.id_name + ".in_(id_list)).order_by(" + > filter_params + ").all()" > > return eval(cmd_str) > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
