pykeepass
Python library to interact with keepass databases (supports KDBX3 and KDBX4)
What it is and what it does
PyKeePass is a Python library for reading and writing KeePass password database files in KDBX3 and KDBX4 formats. It provides an object-oriented interface to load a database, query entries and groups by name or regex, retrieve passwords and OTP codes, and modify the database structure—adding or deleting entries and groups, managing attachments, and updating metadata like creation and modification times.
The library handles the cryptographic details of KeePass database encryption and decryption internally, relying on pycryptodomex for symmetric encryption, argon2_cffi for key derivation, and lxml for XML parsing. It's designed for automation scenarios where you need programmatic access to KeePass data—such as credential provisioning, backup scripts, or integration with other tools—rather than interactive password management.
Use it for:
- Automate credential retrieval in deployment or CI/CD pipelines by querying a KeePass database for usernames and passwords.
- Bulk import or export credentials to/from a KeePass database as part of a migration or backup workflow.
- Generate and store one-time passwords (OTP) by parsing otpauth URIs stored in KeePass entries.
- Programmatically organize credentials by creating groups and entries in a KeePass database from external data sources.
- Attach files (certificates, keys, documents) to KeePass entries and retrieve them programmatically.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Read, write, and manipulate KeePass password database files (KDBX3 and KDBX4 formats) programmatically, including entries, groups, attachments, and OTP codes.
Yes, with conditions. Install if you need programmatic access to KeePass databases and can accept the GPL-3.0 copyleft constraint. The library is actively maintained, has low install friction, carries no known vulnerabilities, and covers the core KeePass operations. Avoid if your project is proprietary or closed-source, or if you need features beyond KDBX3/KDBX4 support.
Install
pykeepass on PyPI
pip
pip install pykeepassuv
uv add pykeepasspoetry
poetry add pykeepassInstalling pykeepass
Before you install
Low friction installation with a pure-Python wheel. Actively maintained with a recent release (5 days old) and steady development activity. Depends on six runtime libraries including cryptography (pycryptodomex, argon2_cffi) and XML parsing (lxml), all standard choices for this use case.
License in practice
GPL-3.0 copyleft license means any code that uses this library must also be released under GPL-3.0 or a compatible license. Not suitable for proprietary or closed-source projects without explicit license negotiation.
Quickstart
from pykeepass import PyKeePass
kp = PyKeePass('db.kdbx', password='somePassw0rd')
entry = kp.find_entries(title='facebook', first=True)
print(entry.password)
kp.save()
Requires lxml system library (e.g., `apt install python3-lxml` on Debian/Ubuntu) before pip install.
Verify before relying
- Whether the library supports all KeePass 2.x database variants beyond KDBX3 and KDBX4.
- Performance characteristics when working with large databases (entry/group count limits).
- Thread safety of concurrent read/write operations on the same database file.
Package facts
| License | GPL-3.0 (copyleft) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 6 — pyotp, importlib-metadata, construct, argon2_cffi, pycryptodomex, lxml |
| Maintenance | actively maintained — 5 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 291,246/month — #7,972 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pykeepass-4.2.0-py3-none-any.whl
Keywords: vault, keepass
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
onepasswordWrapper around the 1Password CLI that lets you…
permissive · top 15,000 on PyPI
onepasswordconnectsdkProvides Python access to 1Password vaults…
permissive · top 15,000 on PyPI
PyOTPPyOTP generates and verifies one-time passwords…
permissive · top 1,000 on PyPI
robocorp-vaultProvides read and write access to secrets…
permissive · top 15,000 on PyPI
onepassword-sdkProgrammatic Python interface to read and…
permissive · top 5,000 on PyPI
firebolt-sdkFirebolt-sdk provides a Python DB API…
permissive · top 15,000 on PyPI
azure-keyvault-secretsSecurely store, retrieve, and manage secrets…
permissive · top 1,000 on PyPI
pyunpackUnpacks archive files in Python with support…
permissive · top 15,000 on PyPI
ansible-vaultReads and writes Ansible vault-encrypted YAML…
copyleft · top 15,000 on PyPI
keeper-secrets-manager-corePython SDK for Keeper Secrets Manager that…
permissive · top 15,000 on PyPI