Skip to main content

DRDA protocol database driver

Project description

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

Requirements

  • Python 3.8+

Installation

$ pip install pydrda

If you want to connect to Db2, you may need to install pyDes.

$ pip install pyDes

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

Apache Derby

https://db.apache.org/derby/

You need to start derby as a network server. http://db.apache.org/derby/papers/DerbyTut/ns_intro.html#start_ns

Example

import drda

conn = drda.connect(host='serverhost', database='dbname', port=1527)
cur = conn.cursor()
cur.execute('select * from foo')
for r in cur.fetchall():
    print(r[0], r[1])

This driver can’t execute with parameters against Apache Derby.

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

Apache Derby

Install Apatch Derby https://db.apache.org/derby/ and start as a server

$ curl -O https://downloads.apache.org//db/derby/db-derby-10.15.2.0/db-derby-10.15.2.0-bin.tar.gz
$ tar zxf db-derby-10.15.2.0-bin.tar.gz
$ echo 'grant {permission java.lang.RuntimePermission "getenv.SOURCE_DATE_EPOCH", "read";};' > ${HOME}/.java.policy
$ db-derby-10.15.2.0-bin/bin/startNetworkServer &

Execute test

$ python test_derby.py

Project details


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.5.1.tar.gz (15.7 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: pydrda-0.5.1.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for pydrda-0.5.1.tar.gz
Algorithm Hash digest
SHA256 ba8e44606a9cc923d641c556437dc834a63f449e80a84d1ff3513ae3b00709c2
MD5 56ea66183561632e9f09ac0cb5ead0eb
BLAKE2b-256 866de97935ea1b23572aecb2c0de2d433554624c76d36b0584b7b4b11100312d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page