Additional tinydb storage
Project description
tinydb-storage
Tiny db storage extension, this is an unofficial from tinydb. I'm creating this extension based on my case only.
Installation
pip install tinydbstorage
Storage extension to use Tinydb
- Memory storage
- File storage
- Redis storage
- S3 storage
Memory storage example
import requests
from tinydb import TinyDB, Query
from tinydbstorage.storage import MemoryStorage
db = TinyDB(storage=MemoryStorage)
def insert_data():
resp = requests.get("https://jsonplaceholder.typicode.com/users")
db.table("users").insert_multiple(resp.json())
File storage example
import os
import requests
from tinydb import TinyDB, Query
from tinydbstorage.storage import FileStorage
db_path = os.path.join(os.path.dirname(__file__), "db.json")
db = TinyDB(path=db_path, storage=FileStorage)
def insert_data():
resp = requests.get("https://jsonplaceholder.typicode.com/users")
db.table("users").insert_multiple(resp.json())
Redis storage example
import requests
from tinydb import TinyDB, Query
from tinydbstorage.storage import RedisStorage
db = TinyDB(storage=RedisStorage, redis_uri="redis://:secret@localhost:6379/0")
def insert_data():
resp = requests.get("https://jsonplaceholder.typicode.com/users")
db.table("users").insert_multiple(resp.json())
S3 storage example
import requests
from tinydb import TinyDB, Query
from tinydbstorage.schema import S3ConfigSchema
from tinydbstorage.storage import S3Storage
config = S3ConfigSchema.parse_obj({
"bucket_name": "foo",
"file_path": "foo/bar/baz.json",
"region_name": "ap-southeast-1",
"access_key_id": "foobar",
"secret_access_key": "foobar",
})
db = TinyDB(storage=S3Storage, config=config)
def insert_data():
resp = requests.get("https://jsonplaceholder.typicode.com/users")
db.table("users").insert_multiple(resp.json())
Help & Bugs
If you are still confused or found a bug, please open the issue. All bug reports are appreciated, some features have not been tested yet due to lack of free time.
License
tinydb-storage released under MIT. See LICENSE for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tinydbstorage-0.1.0.tar.gz.
File metadata
- Download URL: tinydbstorage-0.1.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.5 Darwin/21.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d383609bb69e847a2f2de2016af2198ce45d056206fbc3be51245c1ea8d1c5a7
|
|
| MD5 |
a3f318d6e1be6591fcde7efb78d9c3b0
|
|
| BLAKE2b-256 |
17b8797102bd7c7e9eb7f8b96349a9cfdfbda3a742da4f255ee92cd5415cd417
|
File details
Details for the file tinydbstorage-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tinydbstorage-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.5 Darwin/21.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2648310d3e3f6ea5ac0914039a2b5d5d443cacc4b45f099fd8e6e08a51fe6c3
|
|
| MD5 |
1bbc62429a7f616dbde74d8335d823a4
|
|
| BLAKE2b-256 |
d93b09cd52f5e1c40eaec00f1d9625c0dded7234974a9f9af97b4bb8af02b47c
|