Re: [sqlalchemy] How to pass list of columns into query method.

2017-04-05 Thread Mayank Soni
> > Thank you very much . Sure , I will try this -- 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

Re: [sqlalchemy] How to pass list of columns into query method.

2017-04-05 Thread Simon King
If the column names are part of the "schools_master" table, then the easiest option is something like this: q = session.query(AAA).limit(100) for row in q: for name in col_names: print '%s = %' % (name, getattr(row, name)) Alternatively: cols = [getattr(AAA, name) for name in

Re: [sqlalchemy] How to pass list of columns into query method.

2017-04-05 Thread Mayank Soni
Thanks Simon for response. Actually column names I am getting from user interface based on user selection that is why i want pass columns in query method dynamically. can you suggest me how can achieve this. On Wednesday, April 5, 2017 at 5:08:50 PM UTC+5:30, Simon King wrote: > > On Wed,

Re: [sqlalchemy] How to pass list of columns into query method.

2017-04-05 Thread Simon King
On Wed, Apr 5, 2017 at 11:10 AM, Mayank Soni wrote: > I am trying to pass list of columns of table into query method using > add_columns method. Below i am mentioning code snipped. > > def LLL(): > Base = automap_base() > class AAA(Base): > __tablename__ =

[sqlalchemy] How to pass list of columns into query method.

2017-04-05 Thread Mayank Soni
I am trying to pass list of columns of table into query method using add_columns method. Below i am mentioning code snipped. def LLL(): Base = automap_base() class AAA(Base): __tablename__ = 'schools_master' Base.prepare(engine, reflect=True) session =