Skip to content Skip to sidebar Skip to footer

SQLAlchemy Show Me That "AttributeError: Type Object 'User' Has No Attribute 'columns'"

I am building a small project use python+Flask+SQLAlchemy, I make a model file following: ################# start of models.py ##################### from sqlalchemy import Column,

Solution 1:

You need to pass in a Table object for CreateTable():

CreateTable(User.__table__)

but if you wanted to see the SQL statements that SQLAlchemy issues you are better off switching on echoing by setting echo=True when creating the connection.

The Flask SQLAlchemy integration layer supports a SQLALCHEMY_ECHO option to set that flag.


Post a Comment for "SQLAlchemy Show Me That "AttributeError: Type Object 'User' Has No Attribute 'columns'""