Lightweight and Efficient Database Alternatives For Python | by Tate Galbraith | Mar, 2022

You don’t always need a big fat relational database

Tate Galbraith
Photo by Leif Christoph Gottwald on Unsplash
Source.
#!/usr/bin/env python3import shelvestore = shelve.open('store')store['data'] = {'one':1, 'two': 2}print(store['data']['one'])store.close()
Source.
import pickledbstore = pickledb.load('store.db', auto_dump=False)store.set('name', 'bob')name = store.get('name')print(name)
Source.
import tinydbstore = tinydb.TinyDB('store.json')store.insert({'name':'bob'})results = store.all()print(results)
Source.
#!/usr/bin/python3import h5pystore = h5py.File("store.hdf5", "w")
dataset = store.create_dataset("test", (10,), dtype='i')
dataset[0] = 1
dataset[1] = 2
dataset[2] = 3
print(dataset[0])
print(dataset[1])
print(dataset[2])
Source.

Leave a Comment