tcdbm — dbm-compatible interface to tokyocabinet.

New in version 0.5.0.

Platforms: POSIX

exception tcdbm.error
Raised when an error specific to tcdbm happens.
This function attempts to guess which of the 4 database types available — TCHDB, TCBDB, TCFDB or TCTDB — should be used to open a given file. Returns the type, raises error if filename is not a Tokyo Cabinet file or if its type is unknown.[, flag="r"[, mode=0o666]])

Open the database file filename and return a corresponding object. If the database file already exists, whichdb() is used to determine its type; if it does not exist, open() will try to deduce the database type from the filename extension; if this doesn’t work, TCHDB will be used.

The optional flag argument can be:

Value Meaning
'r' Open existing database for reading only (default)
'w' Open existing database for reading and writing
'c' Open database for reading and writing, creating it if it doesn’t exist
'n' Always create a new, empty database, open for reading and writing

The optional mode argument is the Unix mode of the file. It defaults to octal 0o666 (and will be modified by the prevailing umask).

The tcdbm database types are wrappers for their corresponding tokyocabinet type. In addition to their counterparts methods and attributes, they implement collections.MutableMapping and should behave, for all intents and purposes, like dict.

class tcdbm.TCHDB
Wrapper for tokyocabinet.HDB.
class tcdbm.TCBDB

Wrapper for tokyocabinet.BDB.

get(key[, default=None[, duplicate=False]])
Return the value for key if key is in the database, else default. If default is not given, it defaults to None, so that this method never raises a KeyError. If key has duplicates and duplicate is False (default), return the value of the first record. If duplicate is True this method returns a tuple of all the values corresponding to key.
class tcdbm.TCFDB
Wrapper for tokyocabinet.FDB.
class tcdbm.TCTDB
Wrapper for tokyocabinet.TDB.

Previous topic

Table Database — TDB

Next topic


This Page