skillfed

pykeepass

Python library to interact with keepass databases (supports KDBX3 and KDBX4)

pykeepass v4.2.0 291.2K downloads/30d#7,972 on PyPI504
Copyleft license GPL-3.0 Active released

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 pykeepass

uv

uv add pykeepass

poetry

poetry add pykeepass

Installing 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

License :: OSI Approved :: GNU General Public License v3 (GPLv3)Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: SecurityTopic :: Software Development :: Libraries

Tags

keepass database pythonkdbx file manipulationpassword manager librarykeepass entry managementread write keepasskdbx parserpassword vault access
password-managementkeepasscryptography

More Libraries packages