https://github.com/keenlycode/shelfdb
A tiny documents database for Python
https://github.com/keenlycode/shelfdb
asyncio database nosql python
Last synced: 11 months ago
JSON representation
A tiny documents database for Python
- Host: GitHub
- URL: https://github.com/keenlycode/shelfdb
- Owner: keenlycode
- License: mit
- Created: 2017-01-03T09:14:34.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2023-08-17T16:05:30.000Z (almost 3 years ago)
- Last Synced: 2025-07-27T03:37:32.369Z (11 months ago)
- Topics: asyncio, database, nosql, python
- Language: Python
- Homepage: https://keenlycode.github.io/shelfdb/
- Size: 3.47 MB
- Stars: 37
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Shelf DB

## Introduction
**Shelf DB** is a tiny document database for Python to stores **documents** or **JSON**-like data.
## Get it
```shell
$ pip install shelfdb shelfquery
```
## Start asyncio server
```shell
$ shelfdb
Serving on ('127.0.0.1', 17000)
Database : db
pid : 12359
```
> uvloop built-in already to make it faster. See [uvloop](https://github.com/MagicStack/uvloop).
## Sync/Async query client through network.
```python
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()
```
## Store data
```python
db.shelf('note').insert({
'title': 'Shelf DB',
'content': 'Simple note',
'datetime': datetime.utcnow()})
```
## Flexible query API with similar syntax
```python
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.
## Regular expression
Python reqular expression `re` can be use inside query function
```python
import re
db.shelf('note')\
.filter(lambda note:
re.match(r'.*DB$', note['title']))\
.run()
```
Tiny
shelfdb ~ 12kB
shelfquery ~ 4kB
Runtime code is small, easy to install. Shelf DB also works on **Raspberry Pi**.