bigdata-highway-analytics/app.py
18796357645 11657ae4f5 上传
2025-03-31 20:06:02 +08:00

28 lines
880 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from flask import Flask
from flask_restful import Api
from flask_sqlalchemy import SQLAlchemy
from App import create_app
app = Flask(__name__)
api = Api(app)
# MySQL所在主机名默认127.0.0.1
HOSTNAME = "localhost"
# MySQL监听的端口号默认3306
PORT = 3306
# 连接MySQL的用户名自己设置
USERNAME = "root"
# 连接MySQL的密码自己设置
PASSWORD = "123456"
# MySQL上创建的数据库名称
DATABASE = "bs_jaotong"
# 通过修改以下代码来操作不同的SQL比写原生SQL简单很多 --》通过ORM可以实现从底层更改使用的SQL
app.config['SQLALCHEMY_DATABASE_URI'] = f"mysql+pymysql://{USERNAME}:{PASSWORD}@{HOSTNAME}:{PORT}/{DATABASE}?charset=utf8mb4"
#指定配置,用来省略提交操作
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
db = SQLAlchemy(app)
app = create_app()
if __name__ == '__main__':
app.run()