Re: [sqlalchemy] Update Username and Password from vault

2023-09-07 Thread Mike Bayer
no, create_engine() does not connect at all. connections occur when you first call `engine.connect()`. From that point, the behavior of subsequent `engine.connect()` calls depends on connection pool configuration. all connection pools have points at which they continue to establish new

Re: [sqlalchemy] Update Username and Password from vault

2023-09-07 Thread Steven Schierholz
That makes sense but doesn't connect only happen once when create_engine() is called? On Thursday, September 7, 2023 at 12:00:35 PM UTC-6 Mike Bayer wrote: > the documentation for this pattern is at > https://docs.sqlalchemy.org/en/20/core/engines.html#generating-dynamic-authentication-tokens

Re: [sqlalchemy] Update Username and Password from vault

2023-09-07 Thread Steven Schierholz
That makes sense but doesn't connect only happen once when create_engine() is called? On Thursday, September 7, 2023 at 12:00:35 PM UTC-6 Mike Bayer wrote: > the documentation for this pattern is at > https://docs.sqlalchemy.org/en/20/core/engines.html#generating-dynamic-authentication-tokens

Re: [sqlalchemy] Update Username and Password from vault

2023-09-07 Thread Mike Bayer
the documentation for this pattern is at https://docs.sqlalchemy.org/en/20/core/engines.html#generating-dynamic-authentication-tokens , and a completely specific example is at https://docs.sqlalchemy.org/en/20/dialects/mssql.html#mssql-pyodbc-access-tokens . Basically your application needs

[sqlalchemy] Update Username and Password from vault

2023-09-07 Thread Steven Schierholz
So I have seen some chats here about cred refresh from vault and some suggestions have been to use @event.listens_for(engine, "do_connect") to update creds when the connection is established. My understanding of this is that connecting to the database should only happen once when my flask

Re: [sqlalchemy] Duplicating a relationship from one ORM model to a subquery model

2023-09-07 Thread Mike Bayer
send viewonly=True to these relationships you make. these are not for writing anyway and that will resolve the overlaps warnings (the warning says as much). On Thu, Sep 7, 2023, at 10:41 AM, zedr...@gmail.com wrote: > Hi Mike, > > Thanks a lot for taking the time to reply… > > Indeed, I came

Re: [sqlalchemy] Duplicating a relationship from one ORM model to a subquery model

2023-09-07 Thread zedr...@gmail.com
Hi Mike, Thanks a lot for taking the time to reply… Indeed, I came to a similar conclusion and worked out what seems like a fairly clean way to copy relationships (assuming they do not use secondary_join). The fact that I cannot seem to update the mapper before the class is created makes my

Re: [sqlalchemy] Duplicating a relationship from one ORM model to a subquery model

2023-09-07 Thread Mike Bayer
On Thu, Sep 7, 2023, at 4:39 AM, zedr...@gmail.com wrote: > > *Is there a clean way to (programmatically) duplicate all relationship from > an existing model, over to a new model (that targets the same table and > selects a subset of columns as a subquery)?* relatonships are fixed to their

[sqlalchemy] Duplicating a relationship from one ORM model to a subquery model

2023-09-07 Thread zedr...@gmail.com
I am trying to (programmatically) create partial views of existing SQLAlchemy models, using a metaclass. A streamlined example, trying to get a subquery view on a model Foo with a relationship bar, would look something like that: class Bar(db.Model): id = db.Column(db.Integer,