Metadata-Version: 2.4
Name: dmPython-pure
Version: 1.0.0
Summary: dmPython 兼容层（纯 Python）：包装 dm-pure 纯 Python 达梦驱动，供 dmSQLAlchemy 等依赖官方 dmPython 的库零修改使用
Author: dm-pure
License: MIT
Keywords: dameng,dm8,dmPython,sqlalchemy,database,纯Python
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: ==3.9.*
Description-Content-Type: text/markdown

# dmPython-pure

纯 Python 实现的 **dmPython 兼容层**：底层转发给 [dm-pure](https://github.com/zhangtao103239/dm8_python_pure)（纯 Python 达梦 DM8 驱动）。

让依赖官方 dmPython 的库（如 [dmSQLAlchemy](https://github.com/DamengDB/dmSQLAlchemy)，方言 `dm+dmPython://`）**零修改**可用——
官方 dmPython 是 C 扩展（`.pyd`），在较新 Python 上编译困难；本包纯 Python，Python 3.8+ 直接可装。

## 安装

```bash
# 方式一：GitHub Releases / PyPI（pyc 字节码版，按 Python 版本选）
pip install dmPython-pure==1.0.0

# 方式二：源码构建（本仓库 shim/ 目录）
cd shim && pip install .
```

> pyc 版 wheel 绑定 Python 版本（`cp310` 只能 Python 3.10 用），请选择与本地 Python 一致的版本。

## 使用（dmSQLAlchemy）

```python
from sqlalchemy import create_engine
from sqlalchemy.orm import declarative_base, Session

engine = create_engine("dm+dmPython://SYSDBA:password@127.0.0.1:5236/")
```

与官方 dmPython 完全相同的用法，无需任何改动。

## 直接使用（DB-API 2.0）

```python
import dmPython
conn = dmPython.connect(host="127.0.0.1", port=5236, user="SYSDBA", password="...")
cur = conn.cursor()
cur.execute("SELECT id, name FROM t WHERE id = ?", [1])
print(cur.fetchall())
conn.close()
```

## 实现说明

- `paramstyle = "qmark"`（与官方 dmPython 一致；SQLAlchemy 方言的 paramstyle 取自 dbapi.paramstyle）
- `INSERT` 后 `lastrowid` 通过 `SELECT @@IDENTITY` 获取
- 补齐官方 Connection 特有属性：`str_case_sensitive` / `local_code` / `server_version` / `current_schema` / `autoCommit`
- 包内含 vendored `dmpy`（dm-pure 驱动），单 wheel 自包含、零外部依赖

## 已知限制

- `nextset` 恒返回 None（不支持多结果集）
- `cursor.var`（OUT/RETURNING 变量）为占位实现，INSERT..RETURNING 尚未完整支持
- 未实现异步（async）方言

## 发布

参考 `.github/workflows/shim-release.yml`：打 `shim-v*` tag 或手动触发，
自动为各 Python 版本构建 pyc 版 wheel 并上传 GitHub Releases / PyPI。
