- Add MySQLConnection class with automatic SQL Server to MySQL translation - Add connection factory to support both SQL Server and MySQL - Update config schema to support MySQL configuration (host, port, db_type) - Update default config to use MySQL (localhost:3306) - Translate table names: [schema].[table] -> schema_table - Translate placeholders: ? -> %s - Translate MERGE statements to INSERT ... ON DUPLICATE KEY UPDATE Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
112 lines
3.0 KiB
Python
112 lines
3.0 KiB
Python
#!/usr/bin/env python
|
||
# -*- coding: utf-8 -*-
|
||
"""
|
||
默认配置值
|
||
|
||
定义所有配置项的默认值。
|
||
"""
|
||
from config.schema import (
|
||
ERPConfig,
|
||
DatabaseConfig,
|
||
PathConfig,
|
||
ExtractionConfig,
|
||
ValidationConfig,
|
||
AppConfig,
|
||
)
|
||
|
||
|
||
# 默认配置
|
||
DEFAULT_APP_CONFIG = AppConfig(
|
||
erp=ERPConfig(
|
||
url="https://68.11.34.30:8082/",
|
||
username="BLDpengqiangqiang",
|
||
password="Cqbld123456.",
|
||
headless=True,
|
||
ignore_https_errors=True,
|
||
auto_close_browser=True,
|
||
),
|
||
database=DatabaseConfig(
|
||
db_type="mysql",
|
||
host="localhost",
|
||
port=3306,
|
||
database="CompanyDB",
|
||
username="remote_user",
|
||
password="3.1415926Beeke",
|
||
# SQL Server fields (not used in MySQL mode)
|
||
server="",
|
||
driver="",
|
||
trust_server_certificate="",
|
||
),
|
||
paths=PathConfig(
|
||
data_dir="D:/python/playwrite/data/",
|
||
production_id_file="ProductionID.txt",
|
||
default_output="离散备料计划维护_合并.xlsx",
|
||
validation_output="物料状态校验结果.xlsx",
|
||
),
|
||
extraction=ExtractionConfig(
|
||
batch_size=100,
|
||
verbose=True,
|
||
auto_convert=True,
|
||
merge_batches=True,
|
||
enable_db_persistence=False, # Disabled by default
|
||
),
|
||
validation=ValidationConfig(
|
||
data_source="database_full",
|
||
use_database=True,
|
||
batch_size=2000,
|
||
enable_crud_operations=False,
|
||
default_manager="",
|
||
match_mode="substring",
|
||
),
|
||
)
|
||
|
||
|
||
# 兼容旧版本的字典格式
|
||
DEFAULT_SETTINGS_DICT = DEFAULT_APP_CONFIG.to_dict()
|
||
|
||
|
||
# MySQL 配置示例(使用时取消注释并注释掉上面的 DEFAULT_APP_CONFIG)
|
||
# MYSQL_APP_CONFIG = AppConfig(
|
||
# erp=ERPConfig(
|
||
# url="https://68.11.34.30:8082/",
|
||
# username="BLDpengqiangqiang",
|
||
# password="Cqbld123456.",
|
||
# headless=True,
|
||
# ignore_https_errors=True,
|
||
# auto_close_browser=True,
|
||
# ),
|
||
# database=DatabaseConfig(
|
||
# db_type="mysql",
|
||
# host="localhost",
|
||
# port=3306,
|
||
# database="CompanyDB",
|
||
# username="mysql_user",
|
||
# password="mysql_password",
|
||
# # SQL Server 字段(MySQL 模式下不使用)
|
||
# server="",
|
||
# driver="",
|
||
# trust_server_certificate="",
|
||
# ),
|
||
# paths=PathConfig(
|
||
# data_dir="D:/python/playwrite/data/",
|
||
# production_id_file="ProductionID.txt",
|
||
# default_output="离散备料计划维护_合并.xlsx",
|
||
# validation_output="物料状态校验结果.xlsx",
|
||
# ),
|
||
# extraction=ExtractionConfig(
|
||
# batch_size=100,
|
||
# verbose=True,
|
||
# auto_convert=True,
|
||
# merge_batches=True,
|
||
# enable_db_persistence=False,
|
||
# ),
|
||
# validation=ValidationConfig(
|
||
# data_source="database_full",
|
||
# use_database=True,
|
||
# batch_size=2000,
|
||
# enable_crud_operations=False,
|
||
# default_manager="",
|
||
# match_mode="substring",
|
||
# ),
|
||
# )
|