python3.6.7haskey_python3.6 flask怎么就创建不了表呢?

from flask import Flask

from flask_sqlalchemy import SQLAlchemy

# from flask.ext.sqlalchemy import SQLAlchemy

#import config

app = Flask(__name__)

app.config['SQLALCHEMY_DATABASE_URI']="mysql+pymysql://root:6187285@127.0.0.1:3306/db_deme2?charset=utf8"

db = SQLAlchemy(app)

class Article(db.Model):

__tablename__ = 'article'

id = db.Column(db.INTEGER, primary_key=True, autoincrement=True)

title = db.Column(db.String(100), nullable=False)

content = db.Column(db.text, nullable=False)

db.create_all()

@app.route('/')

def index():

return 'Hello, World!'

if __name__ == '__main__':

app.run(debug=True)

以下是报错信息:

AttributeError: 'function' object has no attribute '_set_parent_with_dispatch'Traceback (most recent call last):

File "E:/PycharmProjects/flaskLeaning/db_demo2.py", line 25, in

class Article(db.Model):

File "E:/PycharmProjects/flaskLeaning/db_demo2.py", line 29, in Article

content = db.Column(db.text, nullable=False)

File "D:\Program Files\Python36\lib\site-packages\sqlalchemy\sql\schema.py", line 1279, in __init__

self._init_items(*args)

File "D:\Program Files\Python36\lib\site-packages\sqlalchemy\sql\schema.py", line 90, in _init_items

item._set_parent_with_dispatch(self)

AttributeError: 'function' object has no attribute '_set_parent_with_dispatch'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值