我尝试构建简单的烧瓶应用。我希望商店服务器的会话在数据库中
from flask import Flask
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
from flask_session import Session
from flask_sqlalchemy import SQLAlchemy
app = Flask( __name__ )
app.config[ 'SQLALCHEMY_DATABASE_URI' ] = 'sqlite://'
app.config[ 'SESSION_TYPE' ] = 'sqlalchemy'
db = SQLAlchemy( app )
Session( app )
Migrate( app, db )
manager = Manager( app )
manager.add_command( 'db', MigrateCommand )
class User( db.Model ):
id = db.Column( db.Integer, primary_key=True )
name = db.Column( db.String( 50 ) )
if __name__ == '__main__':
manager.run()
当我使用flask cli for db init时,会话表未创建:
flask db init
flask db migrate
migrate-file的一部分:
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('user',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=50), nullable=True),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
表'会话'缺少
答案 0 :(得分:0)