dm-pure:纯 Python 达梦 DM8 数据库驱动
零 native 依赖、100% Python 实现的达梦 DM8 数据库驱动,适合无编译环境的机器。
源码版 wheel(py3-none-any),任何 Python 3.8+ 通用。
功能
参数化查询(含 NULL)/ 中文(自动检测服务器编码)/ 大结果集分批 fetch / CLOB·BLOB / 事务 / 存储过程 / 批量插入 executemany / 连接池 / DB-API 2.0 兼容层。
安装
pip install dm-pure
零依赖:加密(DES/AES/RC4)内置纯 Python 实现;若安装 pycryptodome 会自动优先使用(性能更优)。
快速上手
from dmpy import DMClient
c = DMClient("127.0.0.1", 5236, "SYSDBA", "password") # 自动检测服务器字符集
c.connect()
c.execute("SELECT id, name FROM t WHERE id = ?", [1]) # → (cols, rows)
c.execute("INSERT INTO t VALUES (?, ?)", [1, "x"]) # → (None, 影响行数)
c.close()
DB-API 2.0(sqlite3/pymysql 风格)
import dmpy.dbapi as dm
conn = dm.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()
SQLAlchemy(专属方言 sqlalchemy.dialects:dm)
需先 pip install sqlalchemy(或 pip install dm-pure[sqlalchemy]):
from sqlalchemy import create_engine, text
# 已注册方言入口点,直接 create_engine("dm://...") 或 create_engine("dm+dmpy://...")
eng = create_engine("dm://SYSDBA:password@127.0.0.1:5236/?encoding=auto")
with eng.connect() as conn:
rows = conn.execute(text("SELECT * FROM proto_test")).fetchall()
print(rows)
# 元数据反射(USER_TAB_COLUMNS / USER_TABLES)
metadata = MetaData()
metadata.reflect(bind=eng)
# ORM 使用
from sqlalchemy.orm import Session, DeclarativeBase
URL 查询参数:encoding(字符集,默认自动检测)、timeout(秒)、auto_reconnect、send_delay。
方言实现见 dmpy/sa_dialect.py,支持 DDL 编译、表/列/视图反射、事务。
环境要求
- Python >= 3.8
- 可达的达梦 DM8 服务器(TCP 5236 端口)
开源协议
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dm_pure-1.3.0-py3-none-any.whl.
File metadata
- Download URL: dm_pure-1.3.0-py3-none-any.whl
- Upload date:
- Size: 45.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
308c0dccd6695c78b2adb99a7ede3ed1744e8a79d2a60615d5c6245f497456c0
|
|
| MD5 |
0a303bc3300d80f8e2fbe2deaefe57ea
|
|
| BLAKE2b-256 |
8dc7e8c2834814209dd929c31ebe4577b3a218fb085b2faf1b353a636dfb1bca
|