24 lines
455 B
Python
24 lines
455 B
Python
import pymysql
|
|
from peewee import MySQLDatabase
|
|
|
|
# 安装 pymysql 作为 MySQLdb
|
|
pymysql.install_as_MySQLdb()
|
|
|
|
# 数据库配置
|
|
db_config = {
|
|
'database': 'hx',
|
|
'user': 'hx',
|
|
'password': 'haxi@123456',
|
|
'host': '192.168.11.30',
|
|
'port': 3306
|
|
}
|
|
|
|
# 全局数据库实例
|
|
db = MySQLDatabase(
|
|
db_config['database'],
|
|
user=db_config['user'],
|
|
password=db_config['password'],
|
|
host=db_config['host'],
|
|
port=db_config['port']
|
|
)
|