I have an existing model that I can't change, written in Flask-SQLAlchemy. I'm writing another app that uses the same model, but without the need for Flask, therefore I'm working with the regular SQLAlchemy module. Unfortunately, I'm getting a lot of: 'AttributeError: module 'DB' has no attribute 'Model' for all kind of attributes - such as Column, Integer, etc Is there a way to use Flask-SQLAlchemy with a regular SQLAlchemy app?
There is an example of one of my Model Class:
class Table_name(Model):
__tablename__ = 'table_name'
id = db.Column(db.INTEGER, primary_key=True)
field1 = db.Column(db.INTEGER, db.ForeignKey('table1.id'), nullable=False)
field2 = db.Column(db.TEXT, nullable=False)
field3 = db.Column(db.INTEGER, db.ForeignKey('table2.id'), nullable=False)
time = db.Column(db.TIMESTAMP, nullable=False)
Unfortunately I can't change them
Flask-SQLAlchemythin wrapper binding for sqlalchemy in a flask. You could use sqlalchemy without flask-sqlalchemy. Without looking code or your effort it is hard to say.