This is the official Python package for NuoDB.
If you haven't already, Download and Install NuoDB. Currently the driver supports Python version 2.7 only.
To run the tests, you will also need pytz.
pip install pytz
Install from source by running
git clone git://github.com/nuodb/nuodb-python.git
cd nuodb-python
sudo python setup.py installOr install from pip
pip install pynuodb
Simple example for connecting and reading from an existing table:
""" This assumes that you have the quickstart database running (test@localhost).If you don't, you can start it by running /opt/nuodb/run-quickstart"""importpynuodbconnection=pynuodb.connect("test", "localhost", "dba", "goalie", options={'schema':'hockey'})
cursor=connection.cursor()
cursor.arraysize=3cursor.execute("select * from hockey")
printcursor.fetchone()Data can be inserted into a table either explicitly within the execute method...
importpynuodbconnection=pynuodb.connect("test", "localhost", "dba", "goalie", options={'schema':'hockey'})
cursor=connection.cursor()
cursor.execute("create table typetest (bool_col boolean, date_col date, "+"string_col string, integer_col integer)")
cursor.execute("insert into typetest values ('False', '2012-10-03', 'hello world', 42)")
cursor.execute("select * from typetest")
printcursor.fetchone()or using variables...
importpynuodbconnection=pynuodb.connect("test", "localhost", "dba", "goalie", options={'schema':'hockey'})
cursor=connection.cursor()
cursor.execute("create table variabletest (bool_col boolean, date_col date, "+"string_col string, integer_col integer)")
test_vals= (False, pynuodb.Date(2012,10,3), "hello world", 42)
cursor.execute("insert into variabletest values (?, ?, ?, ?)", test_vals)
cursor.execute("select * from variabletest")
printcursor.fetchone()For further information on getting started with NuoDB, please refer to the NuoDB wiki
