User Tools

Site Tools


snippets:python:db

This is an old revision of the document!


Snippets: Python: Datenbanken

pickledb

Beispiel

Das Beispiel von der pickledb-Webseite:
  1. from pickledb import PickleDB
  2.  
  3. # Bind to a JSON file; no I/O yet
  4. db = PickleDB("data.json")
  5. db.load()
  6.  
  7. db.set("username", "alice")
  8. db.set("theme", {
  9. "color": "blue",
  10. "font": "sans-serif"
  11. })
  12.  
  13. print(db.get("username")) # → "alice"
  14.  
  15. db.save() # atomically write to disk
snippets/python/db.1775060091.txt.gz · Last modified: by malte70