This Python script compares two KeePassXC databases (.kdbx files) and logs differences in entries, such as usernames and passwords. It uses the pykeepass library to read the databases and click for command-line argument parsing.
- Compares entries by title, username, and password.
- Identifies entries unique to each database.
- Handles entries with missing titles (
None). - Provides detailed logging with timestamps.
- Securely prompts for passwords without displaying them.
- Python 3.6 or higher installed.
- Access to two KeePassXC
.kdbxfiles and their respective passwords.
To isolate dependencies, create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activatepython -m venv venv
venv\Scripts\activateOnce activated, your terminal prompt should indicate the virtual environment (e.g., (venv)).
Install the required Python packages:
pip install pykeepass clickIf you want to run the script directly:
chmod +x compare_keepass.pyRun the script with paths to the two .kdbx files as arguments. You will be prompted to enter the passwords securely.
python compare_keepass.py --db1-path ./database1.kdbx --db2-path ./database2.kdbxOR (if executable):
./compare_keepass.py --db1-path ./database1.kdbx --db2-path ./database2.kdbxYou’ll be prompted for passwords:
db1-password: [hidden input]
db2-password: [hidden input]
For detailed debugging output:
python compare_keepass.py --db1-path ./database1.kdbx --db2-path ./database2.kdbx --verbose- Ensure the
.kdbxfiles are accessible and readable. - The script does not modify the databases; it only reads them.
- Entries without titles are excluded from comparison but logged as warnings.
- Invalid password error: Double-check the passwords for each database.
- File not found: Verify the file paths are correct.
- Module not found: Ensure dependencies are installed in the active virtual environment.