A quick script with SQL table schema. If tuple is a hack, then how should I it work with the same logic, but without tuple? Construct a string from tuple? I'm afraid that will be double quoted (sanitized) too.
from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker engine = create_engine('mysql://root@localhost/preferences', echo=False) Session = sessionmaker(bind=engine) session = Session() #CREATE TABLE `preferences` ( # `recipient` varchar(255) COLLATE latin1_general_ci NOT NULL, # `col1` tinyint(1) NOT NULL DEFAULT '1', # `col2` tinyint(1) NOT NULL DEFAULT '1', # `col3` tinyint(1) NOT NULL DEFAULT '1', # PRIMARY KEY (`recipient`) #) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci recipients1=["recipient1"] recipients2=["recipient1","recipient2","recipient3"] sql_query="SELECT col1, col2, col3 FROM preferences WHERE recipient IN :recipients" # multi value array # this fail because of double quotes user_configs = session.execute(sql_query, dict(recipients=tuple(recipients2))).fetchall() print user_configs # single value array # this fails because of mysql syntax errox (tuple inserted incorrectly) user_configs = session.execute(sql_query, dict(recipients=tuple(recipients1))).fetchall() print user_configs 2015 m. kovas 23 d., pirmadienis 16:45:48 UTC+2, Edgaras Lukoševičius rašė: > > Hello, > > as I'm not receiving any responses in stackoverflow I wil try here. Can > someone help me with this issue? > > > http://stackoverflow.com/questions/29195825/sqlalchemy-double-quoting-list-items > -- 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 http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.