feat: add MySQL database support with SQL translation
- 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>
This commit is contained in:
@@ -26,12 +26,16 @@ DEFAULT_APP_CONFIG = AppConfig(
|
||||
auto_close_browser=True,
|
||||
),
|
||||
database=DatabaseConfig(
|
||||
server="192.168.110.114",
|
||||
db_type="mysql",
|
||||
host="localhost",
|
||||
port=3306,
|
||||
database="CompanyDB",
|
||||
username="peng",
|
||||
password="Cqbld123456.",
|
||||
driver="ODBC Driver 18 for SQL Server",
|
||||
trust_server_certificate="yes",
|
||||
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/",
|
||||
@@ -59,3 +63,49 @@ DEFAULT_APP_CONFIG = AppConfig(
|
||||
|
||||
# 兼容旧版本的字典格式
|
||||
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",
|
||||
# ),
|
||||
# )
|
||||
|
||||
Reference in New Issue
Block a user