[sqlalchemy] Re: load_only when loading relatinoships from an instance

2023-01-04 Thread 'Tony Cosentini' via sqlalchemy
Ok, I was able to at least create a script that easily reproduces what I'm seeing - https://gist.github.com/tonycosentini/22f42455c5068898efa473760e4f65ed We have some code that runs before our tests to ensure all the tables are empty. When that runs, load_only doesn't seem to work. It sounds b

[sqlalchemy] Re: load_only when loading relatinoships from an instance

2023-01-04 Thread 'Tony Cosentini' via sqlalchemy
Funny enough, this is what I tried. I just wrote up a small sample script using defaultload + load_only and sure enough it works. There must be something in the code base I'm working with that prevents the load_only bit from being applied. I'm pretty sure defaultload is woroking fine. I'll repo

Re: [sqlalchemy] Re: this is a test message

2023-01-04 Thread Mike Bayer
continuing to test On Wed, Jan 4, 2023, at 7:32 PM, Michael Bayer wrote: > this is...another test! imagine that > > On Wednesday, January 4, 2023 at 7:27:10 PM UTC-5 Mike Bayer wrote: >> __ >> test > > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www

[sqlalchemy] Re: this is a test message

2023-01-04 Thread Michael Bayer
this is...another test! imagine that On Wednesday, January 4, 2023 at 7:27:10 PM UTC-5 Mike Bayer wrote: > test > -- 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 E

[sqlalchemy] this is a test message

2023-01-04 Thread Mike Bayer
test -- 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 because

[sqlalchemy] Re: after_update event is fired when I save a many-to-many relationship

2023-01-04 Thread Michael Bayer
the net-change to "user1.teams" is likely sending it through the "after_update" event but no net SQL is being emitted if no actual columns have changed on user1. you would need to adjust the logic in your application to more specifically check for those conditions in which you want to act upon

[sqlalchemy] Re: How to generate view columns in mapped class with async postgresql

2023-01-04 Thread Michael Bayer
the async aspect here is not that important, for Declarative + reflection you likely should look at DeferredReflection: https://docs.sqlalchemy.org/en/14/orm/declarative_tables.html#using-deferredreflection for async, where it has in the example: Reflected.prepare(engine) you would instead say

[sqlalchemy] Re: SQLAlchemy with MySQL on AWS Lambda is taking long time to truncate table

2023-01-04 Thread Michael Bayer
is truncate happening in some other process? does it speed up once you kill the initial python process? does this truncate take time with other kinds of INSERT statements? is the table very large? overall you need to perform more observations here as to what conditions cause this "trunc

[sqlalchemy] Re: getting raw of the query

2023-01-04 Thread Michael Bayer
using logging is the most direct way, however if you want to programmatically intercept all SQL you can use before_cursor_execute: https://docs.sqlalchemy.org/en/14/core/events.html#sqlalchemy.events.ConnectionEvents.before_cursor_execute On Thursday, December 8, 2022 at 9:31:56 AM UTC-5 yahme..

[sqlalchemy] Re: Does SQLAlchemy Core support MERGE?

2023-01-04 Thread Michael Bayer
we don't support the SQL standard MERGE directly right now but you can always emit this statement using text(). We support only the MySQL / PostgreSQL / SQlite driver specific INSERT..ON CONFLICT kinds of statements directly right now. On Sunday, December 11, 2022 at 11:34:43 AM UTC-5 mkmo...

[sqlalchemy] Re: load_only when loading relatinoships from an instance

2023-01-04 Thread Michael Bayer
yeah you can use defaultload.load_only defaultload(ModelA.model_b).load_only(ModelB.only_field) On Wednesday, January 4, 2023 at 3:15:02 AM UTC-5 to...@revenuecat.com wrote: > Hi, > > This might be a strange question, but I tried to find this in the > documentation to no avail. > > Is it po

[sqlalchemy] load_only when loading relatinoships from an instance

2023-01-04 Thread 'Tony Cosentini' via sqlalchemy
Hi, This might be a strange question, but I tried to find this in the documentation to no avail. Is it possible to use something like load_only to override which columns are loaded in when loading a relationship (as in, a relationship that is not loaded at first with the original query)? Some

Re: [sqlalchemy] Large increase in memory use when upgrading from 1.3 to 1.4

2023-01-04 Thread 'Tony Cosentini' via sqlalchemy
Somehow I never followed up on this one, sorry :( We upgraded to 1.4.44 and indeed did see a big decrease in memory usage. However, with how we are using gunicorn there's still a noticable jump in memory usage with the cache enabled, however it's not nearly as large as before. We're still runn