标签:object rom name ima username user word .com charset
Flask配置文件
在项目文件夹下新建一个“config”py文件,在代码中“import config”后使用“app.config.from_object(config)”即可使用配置文件中的参数(需大写),例如:
1 # 数据库连接固定格式格式字符串 2 # dialect+driver://username:password@host:port/database 3 DIALECT = ‘mysql‘ 4 DRIVER = ‘mysqldb‘ 5 USERNAME = ‘root‘ 6 PASSWORD = 123456 7 HOST = ‘127.0.0.1‘ 8 PORT = ‘3306‘ 9 DATABASE = ‘db_demo1‘ 10 11 SQLALCHEMY_DATABASE_URI = ‘{dialect}+{driver}://{username}:{password}@{host}:{port}/{database}?charset=utf8‘.format( 12 dialect=DIALECT, driver=DRIVER, username=USERNAME, password=PASSWORD, host=HOST, port=PORT, database=DATABASE 13 )
标签:object rom name ima username user word .com charset
原文地址:https://www.cnblogs.com/guyuyun/p/9136805.html