Skip to main content

dmPython-pure

纯 Python 实现的达梦 DM8 数据库驱动接口(dmPython),底层为 dm-pure(纯 Python 达梦驱动),零 native 依赖。 它既是官方 dmPython 的 drop-in 兼容层,也自带 SQLAlchemy 方言。

pip install dmPython-pure                          # 基础
pip install dmPython-pure[sqlalchemy]              # 连带 SQLAlchemy 方言

源码版 wheel(py3-none-any),任何 Python 3.8+ 通用。

SQLAlchemy(自带方言 sqlalchemy.dialects:dm)

装了 [sqlalchemy] 后,直接 create_engine("dm://...") 或 create_engine("dm+dmpy://..."):

from sqlalchemy import create_engine, text
from sqlalchemy.orm import Session, DeclarativeBase, Mapped, mapped_column

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_TABLES / USER_TAB_COLUMNS)
metadata = MetaData()
metadata.reflect(bind=eng)

# ORM
class User(DeclarativeBase):
    pass

URL 查询参数:encoding(字符集,默认握手自动检测)、timeout(秒)、auto_reconnect、send_delay。 方言实现见 dmPython/sa_dialect.py:支持 DDL 编译、表/列/视图反射、事务。

也兼容官方 dmSQLAlchemy 方言:create_engine("dm+dmPython://...")(dmPython-pure 是官方 dmPython 的纯 Python 替代,签名对齐,dmSQLAlchemy 零修改可用)。

直接使用(官方 dmPython 同款接口)

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()

连接参数

dmPython.connect() 支持:host / port / user / password / autoCommit / local_code / connection_timeout 等,与官方 dmPython 一致。

开源协议

MIT License。源码:https://github.com/zhangtao103239/dm8_python_pure/tree/main/shim

Metadata

Release files for dmPython-pure 1.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for dmPython-pure 1.0.10
File Interpreter ABI Platform
dmpython_pure-1.0.10-py3-none-any.whl Python 3 none any Details

Release files / dmpython_pure-1.0.10-py3-none-any.whl

Download URL dmpython_pure-1.0.10-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
75d8d8ca79dd3790522b0cc1e963751097fe3d16fcee05a6fa2ceac53c92142c
BLAKE2b-256 checksum
How to use checksums
b490ff792f23dd1982745620396e190027f9a26e9e173d19b7249ecfab1cb79d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Security for dmPython-pure 1.0.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page