Files
playwrite/config/defaults.py
Misaka Server f02858d5dc 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>
2026-02-09 20:12:32 +08:00

112 lines
3.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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",
# ),
# )