2. sqlite3dbm.sshelve — Shelve extention for a sqlite3dbm.dbm object

This module provides a subclass of shelve.Shelf that works for a sqlite3dbm.dbm object. See the documentation for shelve.Shelf to see the context this module fits into.

2.1. Module Contents

sqlite3dbm.sshelve.open(filename[, flag='c'[, mode=0666[, protocol=None[, writeback=False]]]])[source]

Open a persistent sqlite3-backed dictionary. The filename specificed is the path to the underlying database.

The flag and mode parameters have the same semantics as sqlite3dbm.dbm.open() (and, in fact, are directly passed through to this function).

The protocl and writeback parameters behave as outlined in shelve.open().

class sqlite3dbm.sshelve.SqliteMapShelf

A subclass of shelve.Shelf supporting sqlite3dbm.dbm.

Exposes select() and get_many() which are available in sqlite3dbm.dbm but none of the other database modules. The dict object passed to the constructor must support these methods, which is generally done by calling sqlite3dbm.dbm.open().

The optional protocol and writeback parameters behave the same as they do for shelve.Shelf.

2.2. Usage Example

>>> import sqlite3dbm
>>> db = sqlite3dbm.sshelve.open('mydb.sqlite3')
>>> db['foo'] = 'bar'
>>> db['baz'] = [1, 2, 3]
>>> db['baz']
[1, 2, 3]
>>> db.select('foo', 'baz')
['bar', [1, 2, 3]]
>>> db.get_many('foo', 'qux', default='')
['bar', '']

See also

Module shelve
General object persistence build on top of dbm interfaces.

Table Of Contents

Previous topic

1. sqlite3dbm — Sqlite-backed dbm

This Page