Skip to main content

database caching for PyKeePass

Project description


pykeepass_cache is a support library for pykeepass. It is a drop-in replacement for pykeepass.PyKeePass which caches databases in a background process to make database access faster.

This is useful in situations where the program is terminated between invocations (e.g. CLI scripts). The background process will automatically shut down after 300 seconds.



pip install pykeepass-cache

Use as a drop-in replacement for pykeepass.PyKeePass:

>>> from pykeepass_cache import PyKeePass
>>> kp = PyKeePass('test.kdbx', 'password', 'keyfile.key')

Significant speedup on database open times:

# initial open.  database decryption takes a long time
>>> timeit.timeit('from pykeepass_cache import PyKeePass;PyKeePass(\'test3.kdbx\', \'password\', \'test3.key\')', number=1)

# database is now cached in background process and opening is nearly instantaneous
>>> timeit.timeit('from pykeepass_cache import PyKeePass;PyKeePass(\'test3.kdbx\', \'password\', \'test3.key\')', number=1)

Configure background server timeout, socket path:

>>> kp = PyKeePass('test.kdbx', 'password', 'keyfile.key', timeout=60, socket_path='/tmp/pykeepass.sock)

Get a dictionary of currently cached databases:

>>> from pykeepass_cache import PyKeePass, cached_databases
>>> kp = PyKeePass('test.kdbx', 'password', 'keyfile.key')
>>> cached_databases()
{'/home/evan/resources/pykeepass_cache/tests/test.kdbx': <pykeepass.pykeepass.PyKeePass object at 0x7f4b85678dd8>}

Manually kill the server

>>> from pykeepass_cache import close
>>> close()


python tests/

Project details

Download files

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

Files for pykeepass-cache, version 2.0.3
Filename, size File type Python version Upload date Hashes
Filename, size pykeepass_cache-2.0.3-py3-none-any.whl (16.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pykeepass-cache-2.0.3.tar.gz (4.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page