Skip to content

flask migrate with multidb gets sqlalchemy.exc.NoReferencedTable error with flask-sqlalchemy 3.x but not 2.5.1 #521

Closed Answered by louking
louking asked this question in Q&A
Discussion options

You must be logged in to vote

It looks like the Table() definition has changed for binds with flask-sqlalchemy 3.x. Compare https://flask-sqlalchemy.palletsprojects.com/en/2.x/binds/

user_favorites = db.Table('user_favorites',
    db.Column('user_id', db.Integer, db.ForeignKey('user.id')),
    db.Column('message_id', db.Integer, db.ForeignKey('message.id')),
    info={'bind_key': 'users'}
)

with https://flask-sqlalchemy.palletsprojects.com/en/3.0.x/binds/

user_table = db.Table(
    "user",
    db.Column("id", db.Integer, primary_key=True),
    bind_key="auth",
)

Not sure why it took me pasting my model into this question to consider that possibility.

I do need to test this, but will close this question at this point…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by louking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants