Shelf DB is a tiny document database for Python to stores documents or JSON-like data.
$ pip install shelfdb shelfquery
$ shelfdb
Serving on ('127.0.0.1', 17000)
Database : db
pid : 12359
uvloop is implemented to make it faster. See uvloop
import shelfquery
# Sync client point to 127.0.0.1:17000
db = shelfquery.db()
# Make it async client
db.asyncio()
# Make it sync client again
db.sync()
db.shelf('note').insert({
'title': 'Shelf DB',
'content': 'Simple note',
'datetime': datetime.utcnow()})
db.shelf('note')\
.filter(lambda note:
note['title'] == 'Shelf DB')\
.sort(key=lambda note: note['datetime'])
.run()
No need to learn more syntax. Let's just query using filter
, slice
,
sort
, map
, reduce
which almost the same to Python built-in functions.
Python reqular expression re
can be use inside query function
import re
db.shelf('note')\
.filter(lambda note:
re.match(r'.*DB$', note['title']))\
.run()
Runtime code is small, easy to install. shelfdb can run on Raspberry Pi.