adewes / blitzdb

Blitz is a document-oriented database for Python that is backend-agnostic. It comes with a flat-file database for JSON documents and provides MongoDB-like querying capabilities.
http://blitzdb.readthedocs.org
MIT License
330 stars 37 forks source link

object file not saved #65

Open flamingtop opened 8 years ago

flamingtop commented 8 years ago

python 2.7.6 & 3.5.32 blitzdb 0.2.12

console commands

from blitzdb import Docment, FileBackend backend = FileBackend('./test-blitz-db') Document({'name', 'myname'}).save(backend)

no errors.

But the object file isn't saved at all.


~ > ls -Ral test-blitz-db
test-blitz-db:
total 16K
drwxrwxr-x  3 shawn 4.0K May 11 15:49 ./
drwxr-xr-x 59 shawn 4.0K May 11 15:53 ../
-rw-rw-r--  1 shawn  254 May 11 15:49 config.json
drwxrwxr-x  4 shawn 4.0K May 11 15:49 document/

test-blitz-db/document:
total 16K
drwxrwxr-x 4 shawn 4.0K May 11 15:49 ./
drwxrwxr-x 3 shawn 4.0K May 11 15:49 ../
drwxrwxr-x 3 shawn 4.0K May 11 15:49 indexes/
drwxrwxr-x 2 shawn 4.0K May 11 15:49 objects/

test-blitz-db/document/indexes:
total 12K
drwxrwxr-x 3 shawn 4.0K May 11 15:49 ./
drwxrwxr-x 4 shawn 4.0K May 11 15:49 ../
drwxrwxr-x 2 shawn 4.0K May 11 15:49 deb83eae6d5942e5b38f11f4ed13dd2c/

test-blitz-db/document/indexes/deb83eae6d5942e5b38f11f4ed13dd2c:
total 8.0K
drwxrwxr-x 2 shawn 4.0K May 11 15:49 ./
drwxrwxr-x 3 shawn 4.0K May 11 15:49 ../

test-blitz-db/document/objects:
total 8.0K
drwxrwxr-x 2 shawn 4.0K May 11 15:49 ./
drwxrwxr-x 4 shawn 4.0K May 11 15:49 ../
adewes commented 8 years ago

You need to call backend.commit() to persist the changes to disk:

http://blitzdb.readthedocs.io/en/latest/backends/file.html#blitzdb.backends.file.Backend.commit

Alternatively, you can set autocommit=True when creating the backend:

backend.autocommit = True