By default, each key maps to exactly one value. By opening a database with dupsort=True, you allow a single key to have multiple values, stored in sorted order. This is ideal for one-to-many relationships (e.g., tags for a document).
Duplicate values are stored in a nested B-tree and are sorted lexicographically. Note that the maximum size of a duplicate value is limited to 511 bytes (matching the maximum key size).
env = lmdb.open('/tmp/test', max_dbs=1)
db = env.open_db(b'edges', dupsort=True)
with env.begin(write=True, db=db) as txn:
txn.put(b'node1', b'node2')
txn.put(b'node1', b'node3')
txn.put(b'node1', b'node4')
txn.put(b'node2', b'node5')