Keepass Databases 1.x/2.x Merging module and command line utility
This project is configured for setuptools
This updates/adds new groups, new entries and new fields. Unfortunatly, due to a bug in pykeepass, it cannot merge attachments.
Usage: merge_keepass [OPTIONS] [INPUT_DATABASES]... OUTPUT_DATABASE
Options:
-p, --password TEXT
-d, --debug
-c, --continue-on-error
--help Show this message and exit.
If you want to directly use this in your python code, you can use the python module keepassmerge as so :
merging multiple databases
from MergeKeepass.keepassmerge import KeepassMerger
from getpass import getpass
input_databases = [
'../db1.kdbx',
'db2.kdbx',
'local/mydb.kdbx',
]
output_database = 'out.kdbx'
password = getpass()
merger = KeepassMerger()
got_errors = merger.merge_databases(input_databases,
output_database,
password,
debug=False,
continue_on_error=False)
if got_errors:
# Errors occurred
pass
else:
# No erros, merging succeeded
pass
merging two databases
from MergeKeepass.keepassmerge import KeepassMerger
from getpass import getpass
database1 = '../db1.kdbx'
database2 = 'local/mydb.kdbx'
output_database = 'out.kdbx'
password = getpass()
merger = KeepassMerger()
try:
merger.merge_two_databases(database1,
database2,
output_database,
password,
debug=False)
except DB1WrongPasswordError:
pass
# Password of database1 is wrong
except DB2WrongPasswordError:
pass
# Password of database2 is wrong
This is just a little project, but feel free to fork, change, extend or correct the code.
When testing, it's convenient to use this nix command to run all the tests while avoiding to build the whole nix derivation :
$ cd /path/to/merge-keepass
$ nix-shell --command "run_test"
merge-keepass is delivered as it is under the well known MIT License.
References that helped