GithubHelp home page GithubHelp logo

pydrda's Introduction

pydrda

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

Requirements

  • Python 3.5+

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_ca_certs='/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 mydb2 --privileged=true -p 50000:50000 -e LICENSE=accept -e DB2INST1_PASSWORD=password -e DBNAME=testdb -v /tmp/db2:/database ibmcom/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

pydrda's People

Contributors

data-henrik avatar nakagami avatar raphgauthier avatar walz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.