python - Must two SQLAlchemy declarative models share the same declarative_base()? -


What is required for succession from the same example of declarative_base () for two SQLAlchemy models Should they participate in the same session? It is likely to be a case of importing two or more modules that define the SQLLM model. Sqlalchemy.ext.declarative import declarative_base base = declarative_base () from the class SomeClass (base): __tablename__ = 'Some_table' id = column (integer, primary_key = true) name = column (string (50)) base 2 = declarative_base () class Other class (base 2): __tablename__ = 'other_table' id = column (integer, primary_key = true) name = column (string (50))

I have been successfully using different declarative basis in a single session. It can be useful when using multiple databases: Each base is created with its own metadata and each metadata is forced to separate the database. Some of your declarative bases can define additional methods or you can use other metaclaces to install those extensions.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -