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_reconnectsend_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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dmpython_pure-1.0.8-py3-none-any.whl (48.3 kB view details)

Uploaded Python 3

File details

Details for the file dmpython_pure-1.0.8-py3-none-any.whl.

File metadata

  • Download URL: dmpython_pure-1.0.8-py3-none-any.whl
  • Upload date:
  • Size: 48.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.14

File hashes

Hashes for dmpython_pure-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 50114b438960f416348efc6cc7156b626563c87c31b010609967aa206cd17371
MD5 d3aaad97aee8260311b9f64131593212
BLAKE2b-256 a0bcf89e5916e721c0e170f7390a99e622063df1bdf2b5de3551e6eca9fd9dad

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.10

1 file

1.0.9

1 file

This release

1.0.8 This release

1 file

1.0.7

1 file

1.0.6

1 file

1.0.5

1 file

1.0.4

1 file

1.0.3

1 file

1.0.2

1 file

1.0.1

6 files

1.0.0

6 files

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