# 无法为 PostgreSQL 方言编译 MySQL 语句

- **ID:** `python/sqlalchemy-exc-unsupported-compilation-error`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

使用了特定于数据库的 SQL 构造（例如 MySQL 函数），但后端数据库不支持。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **Use generic SQLAlchemy functions** (90% 成功率)
   ```
   Use SQLAlchemy's generic functions like func.now() instead of MySQL-specific NOW().
   ```
2. **Use compatible backend** (85% 成功率)
   ```
   Switch to a compatible database backend or use database-specific dialects with proper abstraction.
   ```

## 无效尝试

- **Changing dialect only** —  (60% 失败率)
- **Using raw SQL blindly** —  (50% 失败率)
