import kvdb db = kvdb.db("colours", drop=True) db.set("red", {"rgb": [255, 0, 0]}) db.set("green", {"rgb": [0, 255, 0]}) db.set("blue", {"rgb": [0, 0, 255]}) db.get() db.set( "red", {"things": [ "Tractor", ]}, ) db.get("red") db.set( "red", {"things": [ "Fire Engine", ]}, ) db.get("red") db.update( "red", { "things": ["Tractor"], }, )
import kvdb from pprint import pprint as pp db = kvdb.db() db.setup() db.set('Do Androids Dream of Electric Sheep', { 'format': 'Paperback', 'pages': '210', 'author': 'Phillip K. Dick' }) db.set('Blade Runner', {'format': 'DVD', 'running_time': '117 minutes'}) db.set( 'Blade Runner 2049', { 'format': 'Blu-Ray', 'running_time': '163 minutes', 'Director': 'Denis Villeneuve' }) pp(db.get('Blade Runner')) db.update('Blade Runner', {'Director': 'Ridley Scott'}) pp(db.get())
import kvdb from pprint import pprint as pp db = kvdb.db("scifi") db.set( "Do Androids Dream of Electric Sheep", { "format": "Paperback", "pages": "210", "author": "Phillip K. Dick" }, ) db.set("Blade Runner", {"format": "DVD", "running_time": "117 minutes"}) db.set( "Blade Runner 2049", { "format": "Blu-Ray", "running_time": "163 minutes", "Director": "Denis Villeneuve", }, ) pp(db.get("Blade Runner")) db.set("Blade Runner", {"Director": "Ridley Scott"}) pp(db.get("Blade Runner"))
from time import sleep from pprint import pprint as pp import kvdb db = kvdb.db(history=True) db.setup() db.set('red', {'rgb': [254, 0, 0]}) sleep(1) db.set('blue', {'rgb': [0, 0, 255]}) sleep(1) db.set('green', {'rgb': [0, 255, 0]}) sleep(1) pp(db.get()) sleep(5) # Opps! Not quite red enough. db.set('red', {'rgb': [255, 0, 0]}) print('Updated') pp(db.get('red')) print('All:') pp(db.get_versions('red')) print('Then:') pp(db.get_first_version('red')) print('All things for all keys:') pp(db.get(when='all'))
from kvdb import db import kvdb from datetime import datetime as dt from datetime import timedelta as td db = kvdb.db("media", drop=True) weekly_watch_list = [ { "title": "Blade Runner", "Director": "Ridley Scott" }, { "title": "Frozen", "Director": ["Chris Buck", "Jennifer Lee"] }, { "title": "Jumanji", "Director": "Joe Johnston" }, { "title": "Labyrinth", "Director": "Jim Henson" }, { "title": "Pixels", "Director": "Chris Columbus" }, { "title": "Jack and Jill", "Director": "Dennis Dugan"