Faheem Mitha wrote: > > Hi, > > I've got a query as follows: > > from sqlalchemy.sql import text > > gq = text(""" > SELECT decode_genotype(cell.snpval_id, snp.allelea_id, > snp.alleleb_id) FROM cell JOIN snp ON snp.fid = > cell.snp_id WHERE cell.patient_chipid IN ('DUKE00001_plateA_A10.CEL', > 'DUKE00001_plateA_A11.CEL') > """) > I want to pass in the tuple as an argument, and was wondering how to do > it. > > So, I'm looking for something conceptually like > > gq = text(""" > SELECT decode_genotype(cell.snpval_id, snp.allelea_id, > snp.alleleb_id) FROM cell JOIN snp ON snp.fid = > cell.snp_id WHERE cell.patient_chipid IN :plist > """) > > gq = conn.execute(gq, plist="('DUKE00001_plateA_A10.CEL', > 'DUKE00001_plateA_A11.CEL')") > > Note, I want to pass in a tuple of arbitary length, so changing this to > pass two string arguments would not do. Perhaps I'm supposed to pass in > some bindparams too, but I don't know what type I should be using.
IN takes a list of scalars, each of which requires its own :bind parameter. On Postgresql you might find it more convenient to use ANY, which takes a single array argument. "WHERE cell.patient_chipid ANY (:plist)" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@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 -~----------~----~----~----~------~----~------~--~---