Re: [sqlalchemy] [alembic] how do I add a many-to-many relation with add_column()

2015-08-11 Thread c.buhtz
On 2015-08-11 21:43 Mike Bayer wrote: > a relationship() is not a Column. Alembic "add_column()" is > intended to render an "ALTER TABLE ADD COLUMN " > statement. You need to pass it a Column object. Ok, tnen how can I realize that. How can I add a relationship to an existing table? Is alembi

[sqlalchemy] What exactly is the rationale behind "manage the life cycle of the session externally to functions that deal with specific data."?

2015-08-11 Thread Jinghui Niu
In the Documentation -- Session Basics, I read this: > E.g. don’t do this: > > >> ### this is the **wrong way to do it** ### > > >> class ThingOne(object): > > def go(self): > > session = Session() > > try: > > session.query(FooBar).update({"x": 5}) > >

Re: [sqlalchemy] [alembic] how do I add a many-to-many relation with add_column()

2015-08-11 Thread Mike Bayer
On 8/11/15 7:12 PM, c.bu...@posteo.jp wrote: I want to add a new column which is a many-to-many relation to a new created table. I am not sure what is wrong with the code below. #!/usr/bin/env python3 # -*- coding: utf-8 -*- import sqlalchemy as sa import sqlalchemy.orm as sao import sqlalchem

[sqlalchemy] [alembic] how do I add a many-to-many relation with add_column()

2015-08-11 Thread c.buhtz
I want to add a new column which is a many-to-many relation to a new created table. I am not sure what is wrong with the code below. #!/usr/bin/env python3 # -*- coding: utf-8 -*- import sqlalchemy as sa import sqlalchemy.orm as sao import sqlalchemy.ext.declarative as sad import sqlalchemy_utils

Re: [sqlalchemy] UnicodeDecode error on sqlalchemy select query

2015-08-11 Thread Mike Bayer
On 8/11/15 1:58 PM, Abhishek Sharma wrote: Hi Team, With asynchronous request my model object Unicode type column not returning Unicode object but if I do same action using synchronous I am getting Unicode object SQLAlchemy has no asynchrnous API itself so this has to do wi

Re: [sqlalchemy] UnicodeDecode error on sqlalchemy select query

2015-08-11 Thread Abhishek Sharma
Hi Team, With asynchronous request my model object Unicode type column not returning Unicode object but if I do same action using synchronous I am getting Unicode object On 05-Aug-2015 11:43 PM, "Abhishek Sharma" wrote: > thanks for your help. > its seems to be working. i will tro

Re: [sqlalchemy] how to auto set foreignkey column?

2015-08-11 Thread Ladislav Lenart
Hello. Please take a look at official examples: http://docs.sqlalchemy.org/en/rel_1_0/orm/backref.html?highlight=back_populates The first two examples use your classes (User and Address). Note the use of backref kw arg in the relationship definition (first example) and back_populates kw arg in t

[sqlalchemy] how to auto set foreignkey column?

2015-08-11 Thread Sean Lin
Dear all, I have a question about how to automatic set the foreignkey column ? we have two class User and Address class User(Base): __tablename__ = 'user' id = Column(Integer, primary_key=True) name = Column(String) addresses = relationship("Address") def __init__(self, id