Skip to content

skhe/dmPython

 
 

Repository files navigation

CI License: MulanPSL-2.0 Python versions macOS ARM64

dmPython-macOS

A Python DB-API 2.0 driver for the Dameng (DM8) database — macOS ARM64 edition with a built-in Go bridge.

This is a community fork of the official dmPython driver. The upstream project relies on a proprietary C library (libdmdpi) that is not available for macOS. This fork replaces it with a Go-based DPI bridge (dpi_bridge/), enabling native macOS ARM64 support without requiring a full Dameng installation.

Installation

Download a pre-built wheel from GitHub Releases:

pip install dmPython_macOS-2.5.32-cp312-cp312-macosx_14_0_arm64.whl

Quick Start

import dmPython

conn = dmPython.connect(
    user="SYSDBA",
    password="SYSDBA001",
    server="localhost",
    port=5236,
)

cursor = conn.cursor()
cursor.execute("SELECT * FROM SYSOBJECTS WHERE ROWNUM <= 5")

for row in cursor.fetchall():
    print(row)

cursor.close()
conn.close()

Documentation

pip install mkdocs
mkdocs serve

Building from Source

Prerequisites:

  • Go 1.21+ (to compile the DPI bridge)
  • Python 3.9 – 3.13
  • DPI header files — place them in ./dpi_include/ or set DM_HOME
# Clone the repository
git clone https://github.com/skhe/dmPython.git
cd dmPython

# Build the wheel
python -m build --wheel

# Or build the extension in-place for development
python setup.py build_ext --inplace

To skip the Go build step (if you already have libdmdpi.dylib):

DMPYTHON_SKIP_GO_BUILD=1 python -m build --wheel

Project Structure

dmPython/
├── setup.py              # Build script
├── pyproject.toml        # Project metadata
├── docs/                 # Project docs (zh README, technical notes)
├── scripts/              # Local/ops scripts
├── src/native/           # C extension sources and headers
├── dpi_bridge/           # Go-based DPI bridge (replaces proprietary libdmdpi)
│   ├── main.go
│   ├── go.mod / go.sum
│   └── ...
├── dpi_include/          # DPI header files (not distributed, see README)
├── src/native/py_Dameng.c/h  # Module entry, type registration, exception hierarchy
├── src/native/strct.h        # Core struct definitions (Environment, Connection, Cursor)
├── src/native/Connection.c   # Connection management
├── src/native/Cursor.c       # Cursor operations, SQL execution
├── src/native/var.c          # Variable management core
├── src/native/v*.c           # Type-specific variable handlers
├── src/native/ex*.c          # External object interfaces (LOB, BFILE, Object)
└── .github/workflows/    # CI: builds macOS ARM64 wheels for Python 3.9–3.13

License

Licensed under Mulan PSL v2.


中文文档 (docs/README_zh.md)

About

Python DB-API 2.0 driver for Dameng (DM8) database — macOS edition with Go bridge

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • C 73.8%
  • Go 14.9%
  • Python 10.7%
  • Other 0.6%