[sqlalchemy] Re: Join SQL not optimal with inheritance

2015-01-30 Thread Jonathan Vanasco
This should generate your second query: q = s.query(Foo)\ .join( Boo, Foo.id == Boo.id )\ .join( Bar, Boo.id == Bar.id )\ .first() -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To

[sqlalchemy] Duplicate constraint name

2015-01-30 Thread Werner
I am getting the following exception on dbCurrent.metadata.create_all(engCurrent) for the Currency class. It is due to the Constraint for 'home' and 'used' columns having the same name. Is this due to the BOOLEAN type and what is the correct way of uniquely naming the Constraint? Is this

Re: [sqlalchemy] Join SQL not optimal with inheritance

2015-01-30 Thread Michael Bayer
Malthe Borch mbo...@gmail.com wrote: On Fri Jan 30 2015 at 4:42:42 PM Jonathan Vanasco jonat...@findmeon.com wrote: This should generate your second query: q = s.query(Foo)\ .join( Boo, Foo.id == Boo.id )\ .join( Bar, Boo.id == Bar.id

Re: [sqlalchemy] Duplicate constraint name

2015-01-30 Thread Michael Bayer
Werner werner...@gmx.ch wrote: I am getting the following exception on dbCurrent.metadata.create_all(engCurrent) for the Currency class. It is due to the Constraint for 'home' and 'used' columns having the same name. Is this due to the BOOLEAN type and what is the correct way of

Re: [sqlalchemy] Re: Join SQL not optimal with inheritance

2015-01-30 Thread Malthe Borch
On Fri Jan 30 2015 at 4:42:42 PM Jonathan Vanasco jonat...@findmeon.com wrote: This should generate your second query: q = s.query(Foo)\ .join( Boo, Foo.id == Boo.id )\ .join( Bar, Boo.id == Bar.id )\ .first() But I already have

[sqlalchemy] Re: Mapping Similar yet different table structures automatically

2015-01-30 Thread m1yag1
ohnathan, I was able to get my code working with your help. I was able to create an automapper of sorts between the two similar tables on the databases. I'm one step closer to getting this done. I have one more question. How would I trigger both saves. For example I've accepted some form

Re: [sqlalchemy] Duplicate constraint name

2015-01-30 Thread Werner
Hi Michael, Yes, I am using the old naming recipe, adjusted it to check for _unnamed_ as a temp fix until I can move to the new way of doing it. Thanks for the fast answer Werner On 1/30/2015 18:27, Michael Bayer wrote: Werner werner...@gmx.ch wrote: I am getting the following exception

[sqlalchemy] Re: Mapping Similar yet different table structures automatically

2015-01-30 Thread m1yag1
Johnathan, I was able to get my code working with your help. I was able to create an automapper of sorts between the two similar tables on the databases. I'm one step closer to getting this done. I have one more question. How would I trigger both saves. For example I've accepted some form

[sqlalchemy] Re: Mapping Similar yet different table structures automatically

2015-01-30 Thread m1yag1
Johnathan, I was able to get my code working with your help. I was able to create an automapper of sorts between the two similar tables on the databases. I'm one step closer to finishing getting this done. I have one more question. How would I trigger this even to take place. For example

[sqlalchemy] Mapping Similar yet different table structures automatically

2015-01-30 Thread m1yag1
The problem I am extracting data from one database and loading the data into another. There isn't much transformation of the data other than the columns are different in each table but a simple conversion of pascal casing to lower_case can be done. For example TestName in my source database

[sqlalchemy] Re: Mapping Similar yet different table structures automatically

2015-01-30 Thread Jonathan Vanasco
You could use sqlacodegen (https://pypi.python.org/pypi/sqlacodegen) to generate your model: • generate both models • generate one model, then regex the other if you make a lookup table/function to map one column name to another, you could also loop over the columns. something sort of like

[sqlalchemy] Join SQL not optimal with inheritance

2015-01-30 Thread malthe
I have a relationship from foo to boo, and the latter inherits from bar: class boo(bar): ... In the following, SQLAlchemy generates (1), but I would like it to generate (2) because this helps PostgreSQL come up with an optimal query plan: -- Query 1: SELECT * FROM foo JOIN (bar

[sqlalchemy] Re: Join SQL not optimal with inheritance

2015-01-30 Thread malthe
On Friday, January 30, 2015 at 12:58:53 PM UTC+1, malthe wrote: -- Query 1: SELECT * FROM foo JOIN (bar JOIN boo ON bar.id = boo.id) ON foo.id = boo.id; -- Query 2: SELECT * FROM foo JOIN boo ON foo.id = boo.id JOIN bar ON bar.id = boo.id; Just for the record, on