Re: [sqlalchemy] Is it considered bad practice to have more than one session instance simultaneously in a web application?

2014-07-01 Thread Jonathan Vanasco
That design is definitely flawed. Read up on the ORM session documentation, and pay attention to Merging, The session encapsulates a bit of logic and a unit of work. Once you close a session, the objects within it are considered to be out-of-phase. Accessing their attributes -- even only for

Re: [sqlalchemy] Postgresql - Index on a json field

2014-07-01 Thread Phillip Aquilina
Ah! I'll give that a try. Thanks Mike. On Monday, June 30, 2014 10:23:13 PM UTC-7, Michael Bayer wrote: per the SO answer, you're looking for CREATE INDEX ON publishers((info-'name'));. Either you can emit this directly as a string, or use Index, just as it states: from sqlalchemy

[sqlalchemy] failed to locate a name error when using model with relationship

2014-07-01 Thread trustedbox
I have two classes, Artwork and Person. Artwork has a relationship to Person. However, when I try to use them, I get an error thrown: InvalidRequestError: When initializing mapper Mapper|Artwork|artwork, expression 'Person' failed to locate a name (name 'Person' is not defined). If this is

Re: [sqlalchemy] failed to locate a name error when using model with relationship

2014-07-01 Thread Mike Bayer
On 7/1/14, 1:17 PM, trusted...@gmail.com wrote: I have two classes, Artwork and Person. Artwork has a relationship to Person. However, when I try to use them, I get an error thrown: InvalidRequestError: When initializing mapper Mapper|Artwork|artwork, expression 'Person' failed to

[sqlalchemy] Regarding the use of reciprocal relationships

2014-07-01 Thread Ken Lareau
Related to one of my recent posted threads here, I'm recalling a certain conversation at PyCon where I was mentioning how a friend would define a many-to-many relationship by defining a relationship on both declarative classes involved, each pointing to the other, and the look of abject horror I

Re: [sqlalchemy] Regarding the use of reciprocal relationships

2014-07-01 Thread Mike Bayer
On 7/1/14, 4:54 PM, Ken Lareau wrote: Related to one of my recent posted threads here, I'm recalling a certain conversation at PyCon where I was mentioning how a friend would define a many-to-many relationship by defining a relationship on both declarative classes involved, each pointing to

Re: [sqlalchemy] Regarding the use of reciprocal relationships

2014-07-01 Thread Ken Lareau
On Tue, Jul 1, 2014 at 2:17 PM, Mike Bayer mike...@zzzcomputing.com wrote: On 7/1/14, 4:54 PM, Ken Lareau wrote: Related to one of my recent posted threads here, I'm recalling a certain conversation at PyCon where I was mentioning how a friend would define a many-to-many relationship by

Re: [sqlalchemy] Regarding the use of reciprocal relationships

2014-07-01 Thread Jonathan Vanasco
If it's just, you want to set up the two relationships as explicit code for readability, that's great, use back_populates. This is probably how apps should be doing it anyway, in the early SQLAlchemy days there was a lot of pressure to not require too much boilerplate, hence backref.

Re: [sqlalchemy] A question regarding hybrid properties, relationships and schema changes

2014-07-01 Thread Ken Lareau
On Thu, Jun 26, 2014 at 7:47 PM, Ken Lareau klar...@tagged.com wrote: On Jun 26, 2014 7:40 PM, Mike Bayer mike...@zzzcomputing.com wrote: right, so a few emails ago I said: you need to put .label('environment') on that column before it finds its way into subq. I dont have the

Re: [sqlalchemy] A question regarding hybrid properties, relationships and schema changes

2014-07-01 Thread Ken Lareau
**SIGH** Please ignore last message... I had forgotten to actually update the database schema itself. :( Pardon me while I go shoot myself... - Ken On Tue, Jul 1, 2014 at 4:19 PM, Ken Lareau klar...@tagged.com wrote: On Thu, Jun 26, 2014 at 7:47 PM, Ken Lareau klar...@tagged.com wrote: On