[sqlalchemy] Subclass not respecting base class' relationship eager loading options

2019-11-28 Thread Carson Ip
Hi Mike, I have having issues letting a subclass load a parent's relationship that configured lazy="joined". Let's say Engineer is a subclass of Person, and Person stores "company_id" and has a relationship called "company" that is lazy="joined". Although I don't have a minimal reproducible ex

Re: [sqlalchemy] Accessing rowid when adding or merging in Oracle

2019-11-28 Thread Javier Collado Jiménez
Is there a way, at least, of preventing commit in every insert? Doing that: for datum in data: statement=table.insert().values(**datum).returning(table.c.rowid) inserted_rowids=conn.execute(statement) rowid=inserted_rowids.fetchone()[0] th

Re: [sqlalchemy] Problems reflecting "dbo" schema dynamically (ORM) in MS SQL Server

2019-11-28 Thread Felipe Araya Olea
Hello Mike, Thanks for your answer. I think I am definitely closer to find the solution thanks to your comments, I created a new table in mssql without using any pre-existing schema and also making sure it has a primary key. I managed to find that table using the code I showed you above and m

[sqlalchemy] Re: Subclass not respecting base class' relationship eager loading options

2019-11-28 Thread Carson Ip
Also, there are some restrictions in my setup such that I am not able to use eager load like session.query(Engineer).options(joinedload(...)).get(). I retrieve the engineer object using another relationship. On Thursday, November 28, 2019 at 5:45:46 PM UTC+8, Carson Ip wrote: > > Hi Mike, > > I

Re: [sqlalchemy] Accessing rowid when adding or merging in Oracle

2019-11-28 Thread Simon King
Sure, use an explicit transaction: https://docs.sqlalchemy.org/en/13/core/connections.html#using-transactions with connection.begin() as trans: # might as well lift this out of the loop insert = table.insert() for datum in data: statement = insert.values(**datum).returning(tab

Re: [sqlalchemy] Problems reflecting "dbo" schema dynamically (ORM) in MS SQL Server

2019-11-28 Thread Felipe Araya Olea
UPDATE! I have gone to the mssql server, manually added a new primary key to the table I was looking for. I used the following SQL code if anyone is interested: ALTER TABLE AssetCashFlows ADD ID INT IDENTITY; ## Then I had to do a second query, to transform ID into a primary key. ALTER TA

Re: [sqlalchemy] Accessing rowid when adding or merging in Oracle

2019-11-28 Thread Javier Collado Jiménez
Thank you! -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message be

Re: [sqlalchemy] Subclass not respecting base class' relationship eager loading options

2019-11-28 Thread Mike Bayer
On Thu, Nov 28, 2019, at 4:45 AM, Carson Ip wrote: > Hi Mike, > > I have having issues letting a subclass load a parent's relationship that > configured lazy="joined". > > Let's say Engineer is a subclass of Person, and Person stores "company_id" > and has a relationship called "company" that

[sqlalchemy] Adding alias to join() makes a wildly different query

2019-11-28 Thread Zsolt Ero
I have the following query: min_values = ( sa.select( [ table.c.region_id, table.c.operator, table.c.day_str, sa.func.min(table.c.processed_time).label('min_processed_time'), ] ) .group

Re: [sqlalchemy] Adding alias to join() makes a wildly different query

2019-11-28 Thread Mike Bayer
On Thu, Nov 28, 2019, at 4:31 PM, Zsolt Ero wrote: > I have the following query: > > min_values = ( > sa.select( > [ > table.c.region_id, > table.c.operator, > table.c.day_str, > sa.func.min(table.c.processed_time).label('min_processed_time'), > ] > ) > .group_by(table.c.region_id, tabl