[sqlalchemy] Re: View DDL Statements with Parameters in Select Statement

2018-10-09 Thread Philip Martin
Ok. I think I got it. From looking at the documentation here , I want to do something like: compiler.sql_compiler.process(create.selectable, literal_binds=True) On Tuesday, October 9, 201

[sqlalchemy] View DDL Statements with Parameters in Select Statement

2018-10-09 Thread Philip Martin
I am attempting to use Sqlalchemy to build views along the table and schema DDL statements. In mainly relied on the view recipe wiki with a couple modifications to build logic for view DDL statements. I've included this code inside my gist

Re: [sqlalchemy] Controlling table dependency for flushing

2018-10-09 Thread Alex Rothberg
Okay with some small tweaks to your original code, I am able to show the issue I am having. comment out flush to see issue: from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class Title(Base): __tabl

[sqlalchemy] joinedload_all or equivalent onto the end of a chain?

2018-10-09 Thread seaders
I've an ORM query that looks like, ActiveAccountStrats.query .options( joinedload_all( ActiveAccountStrats.strats, AccountStrat.account), *(joinedload_all( ActiveAccountStrats.strats, AccountStrat.strat, col) for col in (Strat.moneyline,

Re: [sqlalchemy] Controlling table dependency for flushing

2018-10-09 Thread Mike Bayer
On Tue, Oct 9, 2018 at 10:44 AM Alex Rothberg wrote: > > In looking at what you wrote doesn't this cause an fk violation (it does for > me): > 2018-10-08 10:18:38,760 INFO sqlalchemy.engine.base.Engine INSERT INTO > employee (title_id, department_id, fund_id) VALUES (%(title_id)s, > %(departmen

Re: [sqlalchemy] Controlling table dependency for flushing

2018-10-09 Thread Simon King
If you run Mike's code exactly, do you get the error? If not, can you edit it to make it more like your code in order to trigger the error? We need to figure out what is special about your situation before we can suggest how to fix it. Simon On Tue, Oct 9, 2018 at 3:46 PM Alex Rothberg wrote: >

Re: [sqlalchemy] Controlling table dependency for flushing

2018-10-09 Thread Alex Rothberg
I should say, I didn't run your exact code but essentially that ordering is what is causing my issues with my code in that the new fund_title is inserted after the new employee. On Tue, Oct 9, 2018 at 10:44 AM Alex Rothberg wrote: > In looking at what you wrote doesn't this cause an fk violatio

Re: [sqlalchemy] Controlling table dependency for flushing

2018-10-09 Thread Alex Rothberg
In looking at what you wrote doesn't this cause an fk violation (it does for me): 2018-10-08 10:18:38,760 INFO sqlalchemy.engine.base.Engine INSERT INTO employee (title_id, department_id, fund_id) VALUES (%(title_id)s, %(department_id)s, %(fund_id)s) RETURNING employee.id 2018-10-08 10:18:38,763 IN