1、创建utils包
(1)在utils中创建links.py脚本
import pymysql.cursors
from sqlalchemy import create_engine
# 清洗前数据库连接url
BEFORE_MYSQL_URL = "mysql+pymysql://root:123456@localhost:3306/before_test?charset=utf8mb4"
mysql_con_before = create_engine(BEFORE_MYSQL_URL)
# 清洗后数据库连接url
AFTER_MYSQL_URL = "mysql+pymysql://root:123456@localhost:3306/after_test?charset=utf8mb4"
mysql_con_after = create_engine(AFTER_MYSQL_URL)
# 清洗前数据库连接字典
BEFORE_LINK_DICT = {
'host': 'localhost',
'port': 3306, # MySQL默认端口
'user': 'root', # mysql默认用户名
'password': '123456',
'db': 'before_test', # 数据库
'charset': 'utf8mb4',
'cursorclass': pymysql.cursors.DictCursor
}
# 清洗后数据库连接字典
AFTER_LINK_DICT = {
'host': 'localhost',
'port': 3306, # MySQ