Commit Graph

2 Commits

Author SHA1 Message Date
Misaka
a520c9a05c fix: add SQL Server to MySQL syntax conversion for parameter placeholders and table names
Automatically convert SQL Server syntax to MySQL-compatible format in
execute_query() and execute_update() methods:

- Parameter placeholders: ? -> %s
- Table names: [dbo].[TableName] -> dbo_TableName
- Column names: [ColumnName] -> ColumnName

This fixes the "Not all parameters were used in the SQL statement" error
that occurred when running queries originally written for SQL Server against
MySQL database.

The conversion is transparent to existing code, allowing SQL queries
throughout the codebase to work with MySQL without modification.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-24 21:49:08 +08:00
Misaka
aaa46ef282 feat: migrate configuration to .env environment variables
This commit implements a complete migration from JSON-based configuration
to .env environment variables, providing better security and flexibility.

Key Changes:
- Add python-dotenv dependency for environment variable support
- Create config/env_loader.py with type conversion utilities
- Add from_env() class methods to all config dataclasses
- Update ConfigLoader to prioritize environment variables
- Add save_to_env() method for .env file management
- Implement database connection factory pattern
- Add base DAO and connection classes for better abstraction
- Support both SQL Server and MySQL with unified interface
- Create migration script (scripts/migrate_to_env.py)
- Update GUI to read/write .env files
- Add comprehensive migration documentation

New Files:
- config/env_loader.py - Environment variable loader
- db/base_connection.py - Base database connection interface
- db/base_dao.py - Base DAO with common utilities
- db/connection_factory.py - Factory for creating connections
- db/mysql_connection.py - MySQL-specific connection
- db/sqlserver_connection.py - SQL Server-specific connection
- db/table_name_converter.py - SQL dialect converter
- scripts/migrate_to_env.py - Configuration migration tool
- docs/ENV_MIGRATION.md - Complete migration guide
- .env.example - Environment variable template

Testing:
- Verified MySQL connection (8.0.44)
- Tested all DAO operations
- Confirmed 150 tables accessible
- Validated configuration loading

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-09 22:39:14 +08:00