fix: 独立建库并整理离线依赖目录
This commit is contained in:
@@ -21,6 +21,10 @@ from urllib.request import Request, urlopen
|
||||
import warnings
|
||||
import zipfile
|
||||
|
||||
|
||||
VENDOR_DIR = Path(__file__).resolve().parent / "vendor"
|
||||
sys.path.insert(0, str(VENDOR_DIR))
|
||||
|
||||
from openpyxl import load_workbook
|
||||
|
||||
|
||||
@@ -43,7 +47,7 @@ DATABASE_HOST = "172.17.0.1"
|
||||
DATABASE_PORT = 3306
|
||||
DATABASE_USER = "root"
|
||||
DATABASE_PASSWORD = "OSp!jmgm@26"
|
||||
DATABASE_NAME = "metrix"
|
||||
DATABASE_NAME = "interference_etl"
|
||||
DATABASE_TABLE = "interference_hourly_summary"
|
||||
|
||||
HEADER_FDD = (
|
||||
@@ -260,6 +264,28 @@ class MySQLSummaryStore:
|
||||
except ImportError as exc:
|
||||
raise ProcessingError("PyMySQL is required for database output") from exc
|
||||
try:
|
||||
bootstrap = pymysql.connect(
|
||||
host=DATABASE_HOST,
|
||||
port=DATABASE_PORT,
|
||||
user=DATABASE_USER,
|
||||
password=DATABASE_PASSWORD,
|
||||
charset="utf8mb4",
|
||||
autocommit=True,
|
||||
connect_timeout=15,
|
||||
read_timeout=60,
|
||||
write_timeout=60,
|
||||
)
|
||||
try:
|
||||
cursor = bootstrap.cursor()
|
||||
try:
|
||||
cursor.execute(
|
||||
f"CREATE DATABASE IF NOT EXISTS `{DATABASE_NAME}` "
|
||||
"CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"
|
||||
)
|
||||
finally:
|
||||
cursor.close()
|
||||
finally:
|
||||
bootstrap.close()
|
||||
return pymysql.connect(
|
||||
host=DATABASE_HOST,
|
||||
port=DATABASE_PORT,
|
||||
@@ -273,7 +299,7 @@ class MySQLSummaryStore:
|
||||
write_timeout=60,
|
||||
)
|
||||
except Exception as exc:
|
||||
raise ProcessingError(f"MySQL connection failed: {exc}") from exc
|
||||
raise ProcessingError(f"MySQL database setup failed: {exc}") from exc
|
||||
|
||||
|
||||
class ApiSource:
|
||||
|
||||
Reference in New Issue
Block a user