python-3.xkeepass

Add additional attribute to keepass record in python


I'm using pykeepass to do bulk modification on several hundred keepass files and I'd like to add some additional attributes to the keepass entries.

I tried to do it like this:

def updateRecord(record, recordParent, recordGrandparent, recordGreatGrandparent, kdbxHandle):
   record.custom_properties["keepass2"] = recordGrandparent
   record.custom_properties["keepass3"] = recordGreatGrandparent
   kdbxHandle.save()
   return record

but this has zero effect (no error message no nothing). From my understanding record.custom_properties is a dict which I should be able to modify.

What do I have to do, to add additional attributes to a keepass file with pykeepass?

Thank you!


Solution

  • Ok I can answer my own question - setting a custom property is done like this:

    record.set_custom_property("keepass2", recordGrandparent)