[sqlalchemy] Using Abstract Base Classes with ORM Table Classes

2021-03-14 Thread Richard Damon
I have a lot of tables that have some similar functionality that I would like to factor out into a base mix-in class that provides some common methods. Some of these methods will want to use a method that must be defined in the actual table ORM class, and would be an abstract method in the base. If

Re: [sqlalchemy] Injecting User info into _history table to track who performed the change

2021-03-14 Thread JPLaverdure
Hi Elmer, Thanks for your reply ! My issue is not with obtaining the info I want to inject (the logged in users's email), I already have that all ready to go :) My whole database is versioned using the history_meta.py example from SQLAlchemy https://docs.sqlalchemy.org/en/13/_modules/examples/v

Re: [sqlalchemy] Relationship between two models without constraints or cascades

2021-03-14 Thread Mike Bayer
I also intended to mention there's an option that might work here, though im not sure, which is to set passive_deletes='all' on both sides , which disables this "nulling out" operation, not sure if it will go all the way for the primary key columns here but it's worth a try: https://docs.sqlalc

Re: [sqlalchemy] Relationship between two models without constraints or cascades

2021-03-14 Thread Mike Bayer
On Sun, Mar 14, 2021, at 7:49 AM, Jack Matthews wrote: > The database I am trying to maintain is a representation of a configuration > file I have scraped from a network device. I have two models that when both > exist in the configuration are related to each other, but it is also possible > t

Re: [sqlalchemy] Foriegn key from one database to another in SQLAlchemy or Alembic

2021-03-14 Thread Mike Bayer
When you want to have objects in different databases in the same server have SQL interactions, you use one engine and then schema-qualify the tables using the "schema" argument: https://docs.sqlalchemy.org/en/14/core/metadata.html#specifying-the-schema-name if OTOH you are talking about two e

[sqlalchemy] Relationship between two models without constraints or cascades

2021-03-14 Thread Jack Matthews
The database I am trying to maintain is a representation of a configuration file I have scraped from a network device. I have two models that when both exist in the configuration are related to each other, but it is also possible that one or the other may not be present. The schemas are included

[sqlalchemy] Foriegn key from one database to another in SQLAlchemy or Alembic

2021-03-14 Thread ai.rese...@gmail.com
Hi all, I highly appreciate your help with the following issue. I have two different databases in MySQL let say db1 and db2. I want to add a foreign key constraint from table db1.tablex to table db2.tabley and also include the corresponding relationship in the declarative mapping. I have to c