Skip to content

Add SQLAlchemy dialect adapter + Python 3.7+ support#35

Closed
jarrenL wants to merge 1 commit into
huaweicloud-samples:masterfrom
jarrenL:feature/sqlalchemy-dialect
Closed

Add SQLAlchemy dialect adapter + Python 3.7+ support#35
jarrenL wants to merge 1 commit into
huaweicloud-samples:masterfrom
jarrenL:feature/sqlalchemy-dialect

Conversation

@jarrenL

@jarrenL jarrenL commented Jun 25, 2026

Copy link
Copy Markdown

新增内容

1. SQLAlchemy 方言适配包 (gaussdb_sqlalchemy/)

  • base.py: GaussDBDialect, A/B/M 兼容模式自动检测和适配
    • M 模式: AUTO_INCREMENT, TIMESTAMP(6), CONCAT(), 反引号, LAST_INSERT_ID
    • A/B 模式: SERIAL, ||, 双引号, RETURNING
  • alembic.py: Alembic 集成, M 兼容 MODIFY COLUMN 语法
  • 连接串: gaussdb://user:pass@host:port/db?sslmode=disable

2. Python 3.7+ 兼容

  • _oids.py: 加 from future import annotations
  • _tz.py: zoneinfo 兼容 backports.zoneinfo (3.7/3.8)
  • pyproject.toml: requires-python >= 3.7, 加 3.7/3.8 classifiers

验证

  • 78 个 gaussdb 包文件 + 3 个方言包文件全部 Python 3.7 语法兼容
  • M 模式 DDL: id INTEGER NOT NULL AUTO_INCREMENT ✅
  • M 模式 TIMESTAMP(6) ✅
  • M 模式 concat → CONCAT() ✅
  • A 模式 DDL: id SERIAL NOT NULL ✅
  • A 模式 concat → || ✅
  • 连接串解析 ✅

新增 gaussdb_sqlalchemy 方言包:
- base.py: GaussDBDialect, A/B/M 兼容模式自动检测和适配
  - M 模式: AUTO_INCREMENT, TIMESTAMP(6), CONCAT(), 反引号, LAST_INSERT_ID
  - A/B 模式: SERIAL, ||, 双引号, RETURNING
- alembic.py: Alembic 集成, M 兼容 MODIFY COLUMN 语法
- 连接串: gaussdb://user:pass@host:port/db?sslmode=disable

Python 3.7+ 兼容:
- _oids.py: 加 from __future__ import annotations
- _tz.py: zoneinfo 兼容 backports.zoneinfo (3.7/3.8)
- pyproject.toml: requires-python >= 3.7, 加 3.7/3.8 classifiers
- pyproject.toml: typing-extensions 版本限制 + backports.zoneinfo 依赖

PR huaweicloud-samples#33 coredump 修复已在 master 中(上一个 commit)
@jarrenL jarrenL closed this Jun 26, 2026
@jarrenL jarrenL deleted the feature/sqlalchemy-dialect branch June 26, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant