in config.py
SQLALCHEMY_BINDS = {
'api': 'postgresql+psycopg2://oharad:dino@localhost:5432/dev_api_02',
'person_indexes': 'postgresql+psycopg2://oharad:dino@localhost:5432/dev_person_ix_01',
'analysis_result': 'postgresql+psycopg2://oharad:dino@localhost:5432/dev_analysis_res_01'
}
in models/__init__.py
ACCOUNT_SCHEMA_NAMESPACE = 'account'
class BaseAppTable(db.Model): __abstract__ = True def to_json(self): return json
in models/account.py
from models import BaseAppTable, db, ACCOUNT_SCHEMA_NAMESPACE
_BASE_TABLE_ARGS = {'info': {'table_namespace': ACCOUNT_SCHEMA_NAMESPACE}}
class BaseAccountTable(object): __bind_key__ = 'api' __table_args__ = _BASE_TABLE_ARGS
class Account(BaseAppTable, BaseAccountTable): __tablename__ = "account" # # need to explicitly code __table_args__ here to use 'tuple, dict' syntax __table_args__ = (UniqueConstraint('name', 'company_id', name='account_uq_ix1'), _BASE_TABLE_ARGS) account_id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(length=50), nullable=False) company_id = db.Column(db.Integer, db.ForeignKey('global.company.company_id'), nullable=False)
class RoleGroup(BaseAppTable, BaseAccountTable): __tablename__ = "role_group" role_group_id = db.Column(UUID, primary_key=True) type_code = db.Column(db.SmallInteger, nullable=False) name = db.Column(db.String(length=100), nullable=False, unique=True)
class AccountCodeNamespace(BaseAppTable):
__tablename__ = "account_code_namespace"
__table_args__ = _BASE_TABLE_ARGS
__bind_key__ = 'api'
You received this message because you are subscribed to a topic in the Google Groups "sqlalchemy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sqlalchemy/7kb-9pSu3Bk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sqlalchemy+...@googlegroups.com.
To post to this group, send email to sqlal...@googlegroups.com.