Re: [sqlalchemy] python customer function

2015-05-08 Thread Jose Soares
Hi Mike, thanks to reply my question. In my case the extract function is unuseful because it needs a datetime to extract parts of it but I don't have a datetime but a codified date. I need to manage a string which is a personal code with info about name, birthday, birth place and gender.

[sqlalchemy] insert from cte regression

2015-05-08 Thread Kristi Tsukida
It looks like in sqlalchemy = 0.9.9 that a insert from cte doesn't get rendered properly. Code: from sqlalchemy import * table = Table(my_table, MetaData(), Column(id, Integer, primary_key=True), Column(name, String(30)), ) c = table.select().cte(c) query = c.select() insert =

[sqlalchemy] Instance state discarded when using joinedload(...).load_only

2015-05-08 Thread Marcus Cobden
I've found some rather unexpected behavior when using joinedload(...).load_only https://bpaste.net/show/57322148e56f The ex.description attribute is loaded on the first result, but not on the second, even though all the data is part of the result. It looks like the data is discarded when the

Re: [sqlalchemy] insert from cte regression

2015-05-08 Thread Mike Bayer
On 5/8/15 3:47 AM, Kristi Tsukida wrote: It looks like in sqlalchemy = 0.9.9 that a insert from cte doesn't get rendered properly. Code: from sqlalchemy import * table = Table(my_table, MetaData(), Column(id, Integer, primary_key=True), Column(name, String(30)), ) c =

Re: [sqlalchemy] insert from cte regression

2015-05-08 Thread Mike Bayer
On 5/8/15 12:10 PM, Mike Bayer wrote: On 5/8/15 3:47 AM, Kristi Tsukida wrote: It looks like in sqlalchemy = 0.9.9 that a insert from cte doesn't get rendered properly. Code: from sqlalchemy import * table = Table(my_table, MetaData(), Column(id, Integer, primary_key=True),

Re: [sqlalchemy] Instance state discarded when using joinedload(...).load_only

2015-05-08 Thread Mike Bayer
On 5/8/15 9:23 AM, Marcus Cobden wrote: I've found some rather unexpected behavior when using joinedload(...).load_only https://bpaste.net/show/57322148e56f The ex.description attribute is loaded on the first result, but not on the second, even though all the data is part of the result.

Re: [sqlalchemy] Updating records and keeping the relationships

2015-05-08 Thread Mike Bayer
On 5/8/15 2:41 PM, Carlus wrote: Hello, Sorry I couldnt find info about in google neither in the documentation, I have a model structure like this one: class Person(Base): __tablename__ ='person' id = Column(Integer, primary_key=True, nullable=False) person_name = Column(String,

[sqlalchemy] Re: insert from cte regression

2015-05-08 Thread Kristi Tsukida
awesome, thanks Michael! On Friday, May 8, 2015 at 12:47:35 AM UTC-7, Kristi Tsukida wrote: It looks like in sqlalchemy = 0.9.9 that a insert from cte doesn't get rendered properly. Code: from sqlalchemy import * table = Table(my_table, MetaData(), Column(id, Integer,

[sqlalchemy] Updating records and keeping the relationships

2015-05-08 Thread Carlus
Hello, Sorry I couldnt find info about in google neither in the documentation, I have a model structure like this one: class Person(Base): __tablename__ = 'person' id = Column(Integer, primary_key=True, nullable=False) person_name = Column(String, nullable=False)

Re: [sqlalchemy] python customer function

2015-05-08 Thread Jonathan Vanasco
Would you be able to use a TypeDecorator? http://docs.sqlalchemy.org/en/latest/core/custom_types.html#sqlalchemy.types.TypeDecorator That will allow you to define a function for handling how sqlalchemy inserts and accesses the data from sql. -- You received this message because you are

[sqlalchemy] Re: contains_eager limited by .first()?

2015-05-08 Thread Jonathan Vanasco
The problem is a behavioral quirk. I'm not sure if this is a regression or not, but I've seen it brought up recently... IIRC: The join creates a matrix result (many rows), but `first()` only pulls the first item from the result. Calling 'one()' will pull all the results, but raise an error

Re: [sqlalchemy] Updating records and keeping the relationships

2015-05-08 Thread Carlus
I was afraid that was the only solution, but how to delete and insert new row with the relationships of the old one? El viernes, 8 de mayo de 2015, 23:59:28 (UTC+2), Michael Bayer escribió: On 5/8/15 5:09 PM, Carlus wrote: Yes exactly, imagine and hotel vanish, and it became into an

Re: [sqlalchemy] Updating records and keeping the relationships

2015-05-08 Thread Mike Bayer
On 5/8/15 5:09 PM, Carlus wrote: Yes exactly, imagine and hotel vanish, and it became into an apartment, i know is a weird situation but the code is just an example. OK so the ORM doesn't support an object changing into a new class in place. You have to emit the UPDATE that you want, and

Re: [sqlalchemy] Updating records and keeping the relationships

2015-05-08 Thread Mike Bayer
On 5/8/15 7:17 PM, Carlus wrote: I was afraid that was the only solution, but how to delete and insert new row with the relationships of the old one? it doesn't seem like you have to. your Person refers to accomodation.id, and you aren't deleting from that table, only UPDATEing the type.