Re: [sqlalchemy] `in_` operator does not supports bound parameter
In order to achieve a single parameter affecting a group of items, the statement would have to be modified at the string level before being passed to the database. The single parameter would need to be expanded into the appropriate number of question marks, and the list of parameters would need to be expanded to suit the values. That or, render the values into the string SQL directly. In the latter case you need to be extremely careful to guard against SQL injection and this is the main reason SQLAlchemy itself tries to avoid shipping features like this in the first place. For SQL processing you can likely use the before_cursor_execute() event to make the changes you want. See http://docs.sqlalchemy.org/en/latest/core/events.html?highlight=before_cursor_execute#sqlalchemy.events.ConnectionEvents.before_cursor_execute . On Nov 3, 2016 11:14 AM, "Chrysovalanto Kousetti"wrote: > I mention the issue here: https://bitbucket.org/zzzeek/ > sqlalchemy/issues/3843/in_-operator-does-not-supports-bound. > > > Using column.in_(bindparam('name')) (to place a variable list of values) > throws exception > > Unfortunately for me func.any doesn't solve it because I'm using SQLite > which does not support ANY. > > > How can I overcome the issue? > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > 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 sqlalchemy+unsubscr...@googlegroups.com. > To post to this group, send email to sqlalchemy@googlegroups.com. > Visit this group at https://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. > -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
Re: [sqlalchemy] .count() hangs indefinitely
On Fri, Nov 4, 2016 at 8:13 AM, James Burkewrote: > Hi All, > > I've run into a odd problem, where calling the count function hangs my code > indefinitely. The odd thing is it was working until recently, so I'm a > little confused. > > customer = > session.query(Customer).filter(Customer.phone_number.contains([message['metadata']['MIN']])) > logger.debug(len(customer.all())) > logger.debug('Works perfectly fine') > logger.debug(customer.count()) > logger.debug('I will never see this') > > Has anybody run into this problem before? > What database are you using? Have you tried logging into it to see if it is actually executing the query? If you run the exact query by hand, does it execute quickly? Adding echo='debug' to your create_engine() call will log the query and parameters, which may help. If you Ctrl-C the process, what does the backtrace look like? Simon -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
[sqlalchemy] .count() hangs indefinitely
Hi All, I've run into a odd problem, where calling the count function hangs my code indefinitely. The odd thing is it was working until recently, so I'm a little confused. customer = session.query(Customer).filter(Customer.phone_number.contains([ message['metadata']['MIN']])) logger.debug(len(customer.all())) logger.debug('Works perfectly fine') logger.debug(customer.count()) logger.debug('I will never see this') Has anybody run into this problem before? -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.