from flask import Flask from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) # 配置连接数据库地址 app.config['SQLALCHEMY_DATAbase_URI'] = 'mysql://root:root@127.0.0.1:3306/myflask' #跟踪数据库的修改 app.config['SQLALCHEMY_TEACK_MODIFICATIONS'] = False db = SQLAlchemy(app) class User(db.Model): __tablename__='users' id = db.Column(db.Integer,primary_key=True,autoincrement=True) usename = db.Column(db.String(100)) password = db.Column(db.String(100)) phone = db.Column(db.String(11)) num = db.Column(db.Integer) if __name__ == "__main__": db.create_all() @app.route('/conn/') def conn(): return '连接成功' if __name__ == '__main__': app.run(debug=True)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)