Skip to main content

This is a DRDA protocol (https://en.wikipedia.org/wiki/DRDA) database driver.

Currently, we support only DB2.

Requirements

  • Python 3.8+

Installation

$ pip install pydrda

pyDes is required and is installed automatically as a dependency.

Supported Databases

Db2

https://www.ibm.com/analytics/db2

Example

No SSL

import drda

conn = drda.connect(host='serverhost', database='dbname', user='user', password='password', port=xxxxx, timeout=30)
cur = conn.cursor()
cur.execute('select * from foo where name=?', ['alice'])
for r in cur.fetchall():
    print(r[0], r[1])

With SSL connection

import drda

conn = drda.connect(host='serverhost', database='dbname', use_ssl=True, user='user', password='password', port=xxxxx)
cur = conn.cursor()
cur.execute('select * from foo where name=?', ['alice'])
for r in cur.fetchall():
    print(r[0], r[1])

With SSL and client certificate

import drda

conn = drda.connect(host='serverhost', database='dbname', use_ssl=True, ssl_client_cert_path='/some/what/path/cert.crt', user='user', password='password', port=xxxxx)

AsyncIO

import asyncio
import drda.aio

async def main():
    conn = await drda.aio.connect(host='serverhost', database='dbname', user='user', password='password', port=xxxxx, timeout=30)
    cur = conn.cursor()
    await cur.execute('select * from foo where name=?', ['alice'])
    for r in await cur.fetchall():
        print(r[0], r[1])
    await conn.close()

asyncio.run(main())

Unit Tests

I have tested the following steps.

Db2

Start Db2 server

$ docker run -itd --name db2 --privileged=true -p 50000:50000 -e LICENSE=accept -e DB2INST1_PASSWORD=password -e DBNAME=testdb --platform=linux/amd64 icr.io/db2_community/db2

Execute test

$ python test_db2.py
$ python test_async_db2.py

Download files

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

Source Distribution

pydrda-0.6.1.tar.gz (24.0 kB view details)

Uploaded Source

File details

Details for the file pydrda-0.6.1.tar.gz.

File metadata

  • Download URL: pydrda-0.6.1.tar.gz
  • Upload date:
  • Size: 24.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for pydrda-0.6.1.tar.gz
Algorithm Hash digest
SHA256 9c7f7bbed8d0d4094cab44d17fa8af7600f99b20af15fec96bb7a0ea40b5c577
MD5 34c2003cc84bee78208f9619e3cd03d2
BLAKE2b-256 3f8094661ba60adc9c673ce2413d6b68965acc58e515ae096e6914a133bf5af0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page