This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

NuoDB Python driver

Project Description

This package contains the community driven pure-Python NuoDB client library that provides both a standard PEP 249 SQL API, a NuoDB administration API. This is a community driven driver with limited support and testing from NuoDB.

Requirements

  • Python – one of the following:
  • NuoDB – one of the following:

If you haven’t done so already, Download and Install NuoDB.

Installation

The last stable release is available on PyPI and can be installed with pip:

$ pip install pynuodb

Alternatively (e.g. if pip is not available), a tarball can be downloaded from GitHub and installed with Setuptools:

$ curl -L https://github.com/nuodb/nuodb-python/archive/master.tar.gz | tar xz
$ cd nuodb-python*
$ python setup.py install
$ # The folder nuodb-python* can be safely removed now.

Example

Here is an example using the PEP 249 API that creates some tables, inserts some data, runs a query, and cleans up after itself:

import pynuodb

options = {"schema": "test"}
connect_kw_args = {'database': "test", 'host': "localhost", 'user': "dba", 'password': "dba", 'options': options}

connection = pynuodb.connect(**connect_kw_args)
cursor = connection.cursor()

stmt_drop = "DROP TABLE IF EXISTS names"
cursor.execute(stmt_drop)

stmt_create = """
CREATE TABLE names (
    id BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    name VARCHAR(30) DEFAULT '' NOT NULL,
    age INTEGER DEFAULT 0
)"""
cursor.execute(stmt_create)

names = (('Greg', 17,), ('Marsha', 16,), ('Jan', 14,))
stmt_insert = "INSERT INTO names (name, age) VALUES (?, ?)"
cursor.executemany(stmt_insert, names)

connection.commit()

age_limit = 15
stmt_select = "SELECT id, name FROM names where age > ? ORDER BY id"
cursor.execute(stmt_select, (age_limit,))
print("Results:")
for row in cursor.fetchall():
    print("%d | %s" % (row[0], row[1]))

cursor.execute(stmt_drop)
cursor.close()
connection.close()

All sorts of management and monitoring operations may be performed through the NuoDB Python API, a few below include listening to database state, and shutting down a database:

import time
from pynuodb import entity

class DatabaseListener(object):
    def __init__(self):
        self.db_left = False

    def process_left(self, process):
        print("process left: %s" % process)

    def database_left(self, database):
        print("database shutdown: %s" % database)
        self.db_left = True

listener = DatabaseListener()
domain = entity.Domain("localhost", "domain", "bird", listener)
try:
    database = domain.get_database("test")
    if database is not None:
        database.shutdown(graceful=True)
        for i in range(1, 20):
            time.sleep(0.25)
            if listener.db_left:
                time.sleep(1)
                break
finally:
    domain.disconnect()

For further information on getting started with NuoDB, please refer to the Documentation.

License

PyNuoDB is licensed under a BSD 3-Clause License.

Release History

Release History

This version
History Node

2.3.2

History Node

2.3.1

History Node

2.3

History Node

2.2

History Node

2.1

History Node

2.0

History Node

0.5

History Node

0.4

History Node

0.3

History Node

0.2

History Node

0.1

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pynuodb-2.3.2.tar.gz (38.1 kB) Copy SHA256 Checksum SHA256 Source Aug 28, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting