[sqlalchemy] Re: Asymmetry between engine.begin() and connection.begin()

2016-02-23 Thread Jonathan Beluch
Actually my example isn't fully correct for the case of passing in a connection not in a transaction but the question remains. On Tuesday, February 23, 2016 at 9:05:03 PM UTC-7, Jonathan Beluch wrote: > > Is there a better way of doing this? Basically I have a function that > takes a

[sqlalchemy] Asymmetry between engine.begin() and connection.begin()

2016-02-23 Thread Jonathan Beluch
Is there a better way of doing this? Basically I have a function that takes a connectable (engine or connection) and I want to start a transaction. However I can't just call .begin() because it could return a Transaction or a Connection depending on what was passed in and I need a connection.

Re: [sqlalchemy] Dependency rule tried to blank-out primary key column when trying to update using association proxy

2016-02-23 Thread Mike Bayer
On 02/23/2016 06:11 PM, Piotr Dobrogost wrote: On Tuesday, February 23, 2016 at 5:44:45 PM UTC+1, Mike Bayer wrote: That the old TextValue objects need to be deleted I understand. What I don't see is what makes SA specifically blank-out primary key column 'text_value.text_id'? the

Re: [sqlalchemy] Custom collection: nested dicts

2016-02-23 Thread Mike Bayer
On 02/23/2016 04:50 PM, Sergey Mozgovoy wrote: Recently I ran into two cases that required some custom collection behavior, and it turned out that what I needed did not exist in SQLAlchemy, so I ended up implementing custom collection classes: 1) Nested mapped collections

Re: [sqlalchemy] alembic del sys.modules[module_id] leading to orm mapper error

2016-02-23 Thread Mike Bayer
On 02/23/2016 03:38 PM, Will Angenent wrote: Hi, I think I’ve finally got to the bottom of it. This triggers the problem: - Load a module with some model classes using imp.load_source - Delete the module from sys.modules - Add a reference to the model classes using _mapper_registry.keys() so

Re: [sqlalchemy] "cache lookup failed" on reflection

2016-02-23 Thread Mike Bayer
On 02/23/2016 11:58 AM, Matt Smith wrote: Hi sqlalchemy! When using sqlalchemy (core) 1.0.8 with redshift-sqlalchemy 0.4.1, I encountered the following exception: | InternalError:(psycopg2.InternalError)cache lookup failed forrelation 3262644 | This is the query it failed on: | SELECT

Re: [sqlalchemy] NoneType not callable exception

2016-02-23 Thread bill . adams
Thanks for your help on this. We'll stick with 0.9 for the time being and keep an eye on the issue. Thanks, Bill On Saturday, February 20, 2016 at 12:28:42 AM UTC-5, Mike Bayer wrote: > > > > On 02/19/2016 11:52 PM, bill@level12.io wrote: > > I got a test case working. It seems that the

[sqlalchemy] Custom collection: nested dicts

2016-02-23 Thread Sergey Mozgovoy
Recently I ran into two cases that required some custom collection behavior, and it turned out that what I needed did not exist in SQLAlchemy, so I ended up implementing custom collection classes: 1) Nested mapped collections

[sqlalchemy] Re: Relationship between two databases

2016-02-23 Thread Jonathan Vanasco
I'm not sure it's doable either... but I wanted to point out something: class WeatherStation(MainBase): class EvaporationData(Base): They are inheriting from different bases, and `Base` is not associated to the same metadata as `MainBase` -- You received this message because you are

[sqlalchemy] "cache lookup failed" on reflection

2016-02-23 Thread Matt Smith
Hi sqlalchemy! When using sqlalchemy (core) 1.0.8 with redshift-sqlalchemy 0.4.1, I encountered the following exception: InternalError: (psycopg2.InternalError) cache lookup failed for relation 3262644 This is the query it failed on: SELECT c.oid FROM pg_catalog.pg_class c LEFT JOIN

Re: [sqlalchemy] Dependency rule tried to blank-out primary key column when trying to update using association proxy

2016-02-23 Thread Mike Bayer
On 02/23/2016 10:47 AM, Piotr Dobrogost wrote: Hi! I'm getting AssertionError: Dependency rule tried to blank-out primary key column 'text_value.text_id' on instance '' error while trying to update row using association proxy ('values') like this: |

[sqlalchemy] Dependency rule tried to blank-out primary key column when trying to update using association proxy

2016-02-23 Thread Piotr Dobrogost
Hi! I'm getting AssertionError: Dependency rule tried to blank-out primary key column 'text_value.text_id' on instance '' error while trying to update row using association proxy ('values') like this: session.add(Text(values={'pl': u'org', 'en': u'org'})) text = session.query(Text).one()

Re: [sqlalchemy] prefix_with for queries with that eager load relationships

2016-02-23 Thread Mike Bayer
On 02/23/2016 04:00 AM, Daniel Kraus wrote: Hi, I want to use mysqls `SQL_CALC_FOUND_ROWS` but when I use `query.prefix_with(...)` it fails when the query eager loads a relationship because sqlalchemy puts the prefix not at the beginning. I'm not sure if I should file a bug report or if it's

Re: [sqlalchemy] SQLAlchemy dynamic & customized Collection Class

2016-02-23 Thread Mike Bayer
On 02/23/2016 01:41 AM, Edouard BERTHE wrote: Hello everybody ! This is a question I have already posted on Stack Overflow , but as none is answering I decided to post it here too :) However I invite

Re: [sqlalchemy] Re: Association Proxy query reference ?

2016-02-23 Thread Mike Bayer
On 02/23/2016 06:47 AM, gio wrote: Hi thanks for your answer Without filter i did not expect any big difference between query(Keyword) or a hypothetical query(User.keywords) but I was thinking it will be nice to do something like this session.query(User.keywords).filter(User ==4)

Re: [sqlalchemy] Relationship between two databases

2016-02-23 Thread Thierry Florac
Hi, I don't think that the solution can come from SQLAlchemy. You may have to create a database link between your two databases to be able to query both of them with a single instruction... Best regards, Thierry 2016-02-23 11:43 GMT+01:00 Mehdi : > Hi > Is it possible two

[sqlalchemy] Re: Association Proxy query reference ?

2016-02-23 Thread gio
Hi thanks for your answer Without filter i did not expect any big difference between query(Keyword) or a hypothetical query(User.keywords) but I was thinking it will be nice to do something like this session. query(User.keywords).filter(User ==4) without joins.. My goal was to have a

[sqlalchemy] Relationship between two databases

2016-02-23 Thread Mehdi
Hi Is it possible two have a one-to-many or many-to-many relationship between two models which they are exist in two different databases? I have two oracle dbs on two different machines on lan. so i've created two engines like: main_engine = create_engine("oracle://user:pass@ip1/sid")

[sqlalchemy] prefix_with for queries with that eager load relationships

2016-02-23 Thread Daniel Kraus
Hi, I want to use mysqls `SQL_CALC_FOUND_ROWS` but when I use `query.prefix_with(...)` it fails when the query eager loads a relationship because sqlalchemy puts the prefix not at the beginning. I'm not sure if I should file a bug report or if it's intended behaviour. If I'm doing something