SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL.
This is very powerful tool to handle databases.
I build o/r mapper for some databases to build QSAR models.(can not show code…)
I want to build query using list, and asked google how to do it.
Then, I found “in_” method.
For exmple, using chembldb…
pychembldb is very cool library.
ids = ['1344708', '1273485', '1273478'] # they are "molregno". from pychembldb import * query = chembldb.query(Molecule) res = query.filter( Molecule.molregno.in_( ids )) for m in res: print m.structure.cannonical_smiles > NC(=O)c1cnc(N)c2cc(sc12)c3ccc(cc3)N4CCOCC4 > CNC(=O)c1cnc(N)c2cc(sc12)c3ccccc3 > C(CN1CCCC1)Oc2ccc3Nc4nccc(n4)c5coc(COC\C=C\COCc2c3)c5
It’s very easy.