{"id":7188,"library":"dmpython","title":"Dameng Database Python Interface","description":"dmPython is the official Python interface to the Dameng database, designed to facilitate connections and operations following the Python DB API 2.0 specification. It enables Python applications to directly interact with Dameng databases. The library is actively maintained by Dameng Database and currently stands at version 2.5.32, with frequent updates addressing bug fixes and new features.","status":"active","version":"2.5.32","language":"en","source_language":"en","source_url":"https://github.com/dm-database/dmPython","tags":["database","dameng","sql","db-api"],"install":[{"cmd":"pip install dmpython","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Required for compiling and installing dmPython from source. Not needed for pip installations using pre-built wheels.","package":"Dameng Database Programmer's Interface (DPI)","optional":true},{"reason":"A compatible SSL encryption module is required to avoid encryption module loading failures.","package":"libssl 1.1+","optional":false}],"imports":[{"symbol":"dmPython","correct":"import dmPython"}],"quickstart":{"code":"import dmPython\nimport os\n\n# Replace with your actual Dameng database connection details\nuser = os.environ.get('DM_USER', 'SYSDBA')\npassword = os.environ.get('DM_PASSWORD', 'Dameng123')\nhost = os.environ.get('DM_HOST', 'localhost')\nport = os.environ.get('DM_PORT', '5236')\nschema = os.environ.get('DM_SCHEMA', 'SCH1')\n\nconnection_string = f'{user}/{password}@{host}:{port}/{schema}'\n\ntry:\n    conn = dmPython.connect(connection_string)\n    cursor = conn.cursor()\n\n    cursor.execute(\"SELECT SYSDATE FROM DUAL\")\n    result = cursor.fetchone()\n    print(f\"Current database time: {result[0]}\")\n\n    cursor.close()\n    conn.close()\nexcept dmPython.DatabaseError as e:\n    print(f\"Database connection or query error: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to establish a connection to a Dameng database, execute a simple query, fetch the result, and properly close the cursor and connection. Ensure you replace the placeholder connection details with your actual database credentials."},"warnings":[{"fix":"For source installation, ensure Dameng Database is installed and `DM_HOME` points to its installation directory. For easier installation, use `pip install dmpython` which typically uses pre-built wheels and avoids this requirement.","message":"When installing dmPython from source (not via `pip install`), the Dameng Database software must be installed and the `DM_HOME` environment variable must be correctly set, as the source build depends on include headers from the DM installation directory.","severity":"gotcha","affected_versions":"All versions (when installing from source)"},{"fix":"Upgrade to `dmPython` version 2.5.30 or newer to benefit from fixes addressing multi-threading and `executemany` stability.","message":"Older versions of `dmPython` (e.g., prior to 2.5.30) had known issues with multi-threaded concurrent connection release, which could lead to application instability. Similarly, versions before 2.5.26 experienced interruptions when using `executemany` with character data containing unidentifiable characters for the current encoding.","severity":"breaking","affected_versions":"< 2.5.30"},{"fix":"Verify that your `import` statements and package installations specifically refer to `dmPython` for database operations.","message":"Be aware that there is another distinct Python library named 'DM_Control_Python' which is used for controlling Damiao motors via CAN. Ensure you are importing and using 'dmPython' for Dameng database connectivity to avoid confusion and unexpected errors.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Update `libssl` to version 1.1 or higher. Alternatively, set the `LD_LIBRARY_PATH` (Linux) or `PATH` (Windows) environment variable to point to the `dmssl` directory located within the `dmPython` installation (e.g., `export LD_LIBRARY_PATH=/usr/local/lib/python3.13/site-packages/dmssl`).","cause":"The system's SSL encryption module does not meet the requirements, or the dmPython driver cannot locate the necessary SSL libraries.","error":"dmPython.DatabaseError: [CODE:-70089]加密模块加载失败"},{"fix":"Install the latest stable version of dmPython using `pip install dmpython` or specify a currently available version on PyPI.","cause":"Specific older versions of dmPython, such as 2.4.5, have been removed from PyPI.","error":"pip install dmpython==2.4.5 fails"}]}