========
Cdblib contains classes to read and write cdb ("constant database") files.
Cdb files map string keys to string values with very fast record lookups.
Cdblib also allows for in-memory indexes to enable even faster lookups.
See http://cr.yp.to/cdb.html on D. J. Bernstein's site for the original
specification.
Installation
============
Cdblib requires Python 2.5.
The cdblib package contains a C extension module for speedups, but its use
is not required and makes no difference to the interfaces exposed (except of
course for speed).
To install with the C extension module for speed, run::
# python setup.py install
Alternatively, you can simply copy the file cdblib.py to somewhere in your
PYTHONPATH (but this will not include the speedups from the C extension).
Example Usage
=============
Create a new CDB (or update an existing one):
>>> from cdblib import CDB, CDBWriter
>>> wcdb = CDBWriter("presidents.cdb") # Create a new CDB file.
>>> wcdb["Reagan"] = "1981 - 1988"
>>> wcdb["Bush"] = "1989 - 1992"
>>> wcdb["Clinton"] = "1993 - 2000"
>>> wcdb["Bush"] = "2001 - 2008" # Creates a second record with the key "Bush".
>>> wcdb["Bush"] # Return the first record with key "Bush".
'1989 - 1992'
>>> wcdb.getall("Bush") # Return all records with the key "Bush".
['1989 - 1992', '2001 - 2008']
>>> wcdb["Clinton"]
'1993 - 2000'
>>> wcdb.getall("Clinton")
['1993 - 2000']
>>> wcdb["Gore"] # Oops, the CDB doesn't contain the key "Gore".
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "cdblib.py", line 135, in __getitem__
raise KeyError(key)
KeyError: 'Gore'
>>> wcdb.get("Gore", "Bush") # Return "Bush" if the key "Gore" doesn't exist.
'Bush'
>>> wcdb.close() # Close the CDB file and prevent any more writes.
Open an existing CDB read-only:
>>> rcdb = CDB("presidents.cdb") # Re-open the saved CDB file read-only.
>>> rcdb["Clinton"]
'1993 - 2000'
>>> rcdb.close()
>>> rcdb = CDB("presidents.cdb", load_index=True) # Load the CDB index into memory for faster lookups.
Metadata
Release files for cdblib 0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cdblib-0.5.zip | 9.6 kB | Without provenance | Details for cdblib-0.5.zip |
Release files / cdblib-0.5.zip
| Download URL | cdblib-0.5.zip |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
95abd49ce3030dd138e689fec4037fa9a25e8d9bb70e230499c5cf0601dc3e38
|
|
BLAKE2b-256 checksum How to use checksums |
c9a9470a1f80f6838c143d2b2e195aea040b0084d131b20fdff3099feea0e02e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for cdblib 0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.