Skip to main content

Python bindings for UnQLite, the embedded NoSQL database.

Project description


Python bindings for [UnQLite](, a lightweight, embedded NoSQL database and JSON document store.

UnQLite features:

* Embedded, zero-conf database
* Transactional (ACID)
* Single file or in-memory database
* Key/value store
* Cursor support and linear record traversal
* JSON document store
* Thread-safe
* Terabyte-sized databases


* [unqlite-python documentation](
* [UnQLite's C API](

## Installation

You can install unqlite using `pip`.

pip install unqlite

## Basic usage

First you instantiate an `UnQLite` object, passing in either the path to the database file or the special string `':mem:'` for an in-memory database.

Below is a sample interactive console session designed to show some of the basic features and functionality of the unqlite-python library. Also check out the [full API documentation](

To begin, instantiate an ``UnQLite`` object. You can specify either the path to a database file, or use UnQLite as an in-memory database.

>>> from unqlite import UnQLite
>>> db = UnQLite() # Create an in-memory database.

### Key/value features

UnQLite can be used as a key/value store.

>>> db['foo'] = 'bar' # Use as a key/value store.
>>> print db['foo']

>>> for i in range(4):
... db['k%s' % i] = str(i)

>>> 'k3' in db
>>> 'k4' in db
>>> del db['k3']

>>> db.append('k2', 'XXXX')
>>> db['k2']

You can also use cursors to traverse the database in key-order:

>>> with db.cursor() as cursor:
... for key, value in cursor:
... print key, '=>', value
foo => bar
k0 => 0
k1 => 1
k2 => 2XXXX

There are many different ways of interacting with cursors, which are described in the [Cursor API documentation](

### Document store features

UnQLite can be used as a JSON document store. The [Jx9 scripting language]( is used to interact with the document store.

>>> script = """
... db_create('users');
... db_store('users', $list_of_users);
... $users_from_db = db_fetch_all('users');
... """

>>> list_of_users = [
... {'username': 'Huey', 'age': 3},
... {'username': 'Mickey', 'age': 5}
... ]

>>> with db.compile_script(script) as vm:
... vm['list_of_users'] = list_of_users
... vm.execute()
... users_from_db = vm['users_from_db']

>>> users_from_db # UnQLite assigns items in a collection an ID.
[{'username': 'Huey', 'age': 3, '__id': 0},
{'username': 'Mickey', 'age': 5, '__id': 1}]

More information can be found in the [VM API documentation](


This code is based in part on nobonobo's [unqlitepy]( library.

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
unqlite-0.1.1.tar.gz (520.9 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page