我有python 2.7.6,烧瓶0.12.2
这是我的models.py文件
import flask_sqlalchemy, app
import os
# app.app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DATABASE_URL')
db = flask_sqlalchemy.SQLAlchemy(app.app)
class Message(db.Model):
id = db.Column(db.Integer, primary_key=True) # key
message = db.Column(db.String(200))
name = db.Column(db.String(200))
pic = db.Column(db.String(1000))
def __init__(self, m, n, p):
self.message = m
self.name = n
self.pic = p
def __repr__(self): # what's __repr__?
return '%s %s %s' % (self.message, self.pic, self.name)
#if __name__ == "__main__":
# messageQuery = Message.query.all()
# print messageQuery

在我的app.py文件中,我导入模型,当我尝试使用
时messageQuery = models.Message.query.all()
Flask连接断开连接。知道为什么吗?