On 03/24/2017 02:24 AM, Vijaya Sekar wrote:
Hi everyone,
I have a 'sqlalchemy.orm.query.Query' object from that how can i know
what model it uses
use column_descriptions:
http://docs.sqlalchemy.org/en/rel_1_1/orm/query.html?highlight=column_descriptions#sqlalchemy.orm.query.Query.column_descriptions
from sqlalchemy import create_engine
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
from sqlalchemy import MetaData
engine = create_engine("sqlite:///chinook.db", echo = False)
metadata = MetaData()
model = 'employees'
metadata.reflect(engine, only=[model])
base = automap_base(metadata=metadata)
base.prepare()
map_model = base.classes[model]
session = Session(engine)
query = session.query(map_model.LastName,map_model.FirstName)
Here the model i am using is 'employees'. But how can achieve this by
using 'sqlalchemy.orm.query.Query' object in the program
(i.e. query = session.query(map_model.LastName,map_model.FirstName)).
--
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
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto: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.