I'm looking for a flat-file, portable key-value store in Python. I'll be using strings for keys and either strings or lists for values. I looked at ZODB but I'd like something which is more widely used and is more actively developed. Do any of the dmb modules in Python require system libraries or a database server (like mysql or the likes) or can I write to file with any of them?
If a dbm does not support a python lists, I imagine that I can just serialize it?
You may want to consider h5py which is a Python interface to HDF5.
In [1]: import h5py
In [2]: f = h5py.File('test.hdf5', 'w')
In [3]: f['abc'] = [1, 2, 3]
In [4]: f['d'] = 'hello'
In [5]: f.close()
In [6]: f2 = h5py.File('test.hdf5', 'r')
In [7]: f2['abc'].value
Out[7]: array([1, 2, 3])
In [8]: list(f2['abc'])
Out[8]: [1, 2, 3]
In [10]: f2['d'].value
Out[10]: 'hello'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With