librelist archives

« back to archive

question about sqlalchemy

question about sqlalchemy

From:
张子腾
Date:
2015-01-13 @ 05:21
hi masters:
    glad to join flask.
   and there are some question about sqlalchemy i still not clear.
   for use sqlalchemy's query object should i must create a model of the 
table at first?? for example,there are table named User and it modeled by 
python class,and then i can use User.query...
   but in fact,in our system,there are many data table wasn't created to a
model in python class.so i only use like db.session.execute(select * from 
...),here no way to use query??or whether there
   are some method to trans an exited table to model so i can use the 
query object???
here they are, wait for some resolusion,thanks


Re: [flask] question about sqlalchemy

From:
linnchord gao
Date:
2015-01-13 @ 07:21
I think you need this package 
sqlacodegen

https://pypi.python.org/pypi/sqlacodegen/1.1.5 
<https://pypi.python.org/pypi/sqlacodegen/1.1.5>

OR

You can use 'autoload=True’ in model declarative.


http://docs.sqlalchemy.org/en/rel_0_8/orm/extensions/declarative.html?highlight=autoload#using-reflection-with-declarative

<http://docs.sqlalchemy.org/en/rel_0_8/orm/extensions/declarative.html?highlight=autoload#using-reflection-with-declarative>



> 在 2015年1月13日,13:21,张子腾 <kaku21@163.com> 写道:
> 
> hi masters:
>     glad to join flask.
>    and there are some question about sqlalchemy i still not clear.
>    for use sqlalchemy's query object should i must create a model of the
table at first?? for example,there are table named User and it modeled by 
python class,and then i can use User.query...
>    but in fact,in our system,there are many data table wasn't created to
a model in python class.so i only use like db.session.execute(select * 
from ...),here no way to use query??or whether there 
>    are some method to trans an exited table to model so i can use the 
query object???
> here they are, wait for some resolusion,thanks
> 
> 
> 
> 

Re: Re: [flask] question about sqlalchemy

From:
张子腾
Date:
2015-01-13 @ 07:30
thx,i 'll try it






At 2015-01-13 15:21:12, "linnchord gao" <linnchord@163.com> wrote:

I think you need this package 
sqlacodegen
https://pypi.python.org/pypi/sqlacodegen/1.1.5


OR


You can use 'autoload=True’ in model declarative.



http://docs.sqlalchemy.org/en/rel_0_8/orm/extensions/declarative.html?highlight=autoload#using-reflection-with-declarative






在 2015年1月13日,13:21,张子腾 <kaku21@163.com> 写道:


hi masters:
    glad to join flask.
   and there are some question about sqlalchemy i still not clear.
   for use sqlalchemy's query object should i must create a model of the 
table at first?? for example,there are table named User and it modeled by 
python class,and then i ca n use User.query...
   but in fact,in our system,there are many data table wasn't created to a
model in python class.so i only use like db.session.execute(select * from 
...),here no way to use query??or whether there
   are some method to trans an exited table to model so i can use the 
query object???
here they are, wait for some resolusion,thanks