フラスコの sqlalchemy を使用して、宣言型クラスを継承するクラスを作成し、__bind_key__
. いくつかのテーブルを作成し、これらのバインドされたクラスを継承できるようにします。
from flask.ext.sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class Model1(db.Model):
__bind_key__ = 'db2'
class Table1(Model1):
__tablename__ = 'table1'
name = db.Column(db.String(100))
しかし、私はいくつかの問題を抱えています:
sqlalchemy.exc.InvalidRequestError: Class <class '__main__.Model1'>
does not have a __table__ or __tablename__ specified
and does not inherit from an existing table-mapped class.
どうすれば解決できますか?