summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Vasile <james@jamesvasile.com>2013-02-09 18:07:36 -0500
committerJames Vasile <james@jamesvasile.com>2013-02-09 18:07:36 -0500
commite9772885f8e86df85a8dcc8e61197e0c787816d0 (patch)
tree29e31375c5b1ee1a30a7547b1d95fb20309c3523
parentbbfdd188597bd55809ca58a46d42f1ef1afdbf69 (diff)
documentation improvements for autcommit and table
-rw-r--r--withsqlite.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/withsqlite.py b/withsqlite.py
index 6a668c7..606f929 100644
--- a/withsqlite.py
+++ b/withsqlite.py
@@ -35,12 +35,23 @@ with sqlite_db("filename") as db:
db['aaa'] = {'test':'ok'}
print db.items()
+Specify a table to have one sqlite db hold multiple dicts:
+
+with sqlite_db("filename", table="fruit") as db:
+ db['citrus'] = ['orange', 'grapefruit']
+ print db.items()
+
+If you change the dict in any way, its state will differ from the
+state of the sqlite database. Changes are committed to disk when you
+close the database connection, manually call commit, or (if you've set
+autocommit to True) after each assignment.
+
BUGS:
vals are json serialized before being written, so if you can't
serialize it, you can't put it in the dict.
-Unimplemented mapping API:
+Unimplemented mapping API:
a.copy() a (shallow) copy of a
a.update([b]) updates a with key/value pairs from b, overwriting existing keys, returns None
a.fromkeys(seq[, value]) Creates a new dictionary with keys from seq and values set to value
@@ -51,6 +62,8 @@ a.iteritems() return an iterator over (key, value) pairs
a.iterkeys() return an iterator over the mapping's keys
a.itervalues() return an iterator over the mapping's values
+TODO: implement that mapping API
+
>>> with sqlite_db("test") as db:
... db.clear()
... db.items()