touchdb
touchdb is a simple document based nosql database built entirely on python. This save the data input which is in python dictionary into a JSON data in a .db file.
There are only limited number of functionalities that are implemented in the engine but they are more than sufficient to handle normal database queries.
Find Me
Installation
Easy to install in your projects using pip.
pip install touchdb
Usage
>>> from touchdb import Database
>>> db = Database.Connector('./record.db', True)
>>> print(db.getByAttribute(record_type='sickness', patient_id='usr1'))
List of functions
load(location, auto_dump): Force the database to load the database from the database file into the memory.dump(): Dump the data in the memory into the database file.insert(**kwargs): Insert the python dictionary data into the database.key - optionalparameter which provide the key for the value to be inserted.valueis pythondictto be inserted into the database.get(key): Get the data from the database using the key.getAll(): Get all the data in the database as JSON format(python dictionary).getByAttribute(**kwargs): Attribute of the record will be checked with the provided values and return the list of mapping data in the database.exists(key): Check if a key exists in the database.remove(key): Remove a particular data mapping to the key in the database.removeByAttribute(**kwargs): Remove all data records in the database which correlate to the attribute value.totalkeys(key=None): If the parameter key is not provided return the total number of keys in the database, but if the key is provided return the number of data records 11. inside that particular dictionary.add(key, value:dict): Add a new key-value pair to the existing data record with key as provided.extend(datas: dict): Extend the database with the provided dictionary data.deldb(): Delete the database from both memory and file.
Sample Data
A sample data record file is given below for testing purpose.
{
"894a9a5d-46e8-11ed-b600-b526d12bcc50": {
"patient_id": "usr1",
"patient_name": "James",
"record_type": "sickness",
"sens_level": 4,
"data": "<THIS IS THE ACTUAL DATA TO BE STORED IN THE DATABASE>"
},
"69840102-479e-11ed-97ec-b526d12bcc50": {
"patient_id": "usr6",
"patient_name": "Kabilan",
"record_type": "sickness",
"sens_level": 3,
"data": "THIS IS A DUMMY SICKNESS DATA FOR NEW USER"
},
"4e4f3d76-47b0-11ed-8752-b526d12bcc50": {
"patient_id": "usr7",
"patient_name": "Levi Ackerman",
"record_type": "drug_prescription",
"sens_level": 3,
"data": "THIS IS A DUMMY DRUG PRESCRIPTION DATA RECORD FOR TESTING"
}
}
A few example code
from touchdb import Database
db = Database.Connector('./record.db', True)
db.insert(value={'test_id':"test123"})
print(db.get(key='cf9a67ed-4bf6-11ed-9284-b72b6fa7f086'))
print(db.getAll())
print(db.getByAttribute(record_type='sickness'))
print(db.exists(key='cf9a67ed-4bf6-11ed-9284-b72b6fa7f086'))
print(db.remove(key='cf9a67ed-4bf6-11ed-9284-b72b6fa7f086'))
print(db.removeByAttribute(record_type='sickness'))
print(db.totalkeys())
print(db.totalkeys(key='69840102-479e-11ed-97ec-b526d12bcc50'))
print(db.add('4e4f3d76-47b0-11ed-8752-b526d12bcc50', {'address':'Eldian Kingdom', 'Kill count':'inf+'}))
Metadata
Release files for touchdb 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| touchdb-0.0.5.tar.gz | 4.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| touchdb-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.7 kB
Release files / touchdb-0.0.5.tar.gz
| Download URL | touchdb-0.0.5.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3e7307e3e4bc3392bf5d9901753ac153c50b04768b96dca920a299185371d1eb
|
|
BLAKE2b-256 checksum How to use checksums |
1121e257d65b75f570263c317e8f335665e469cf13ecbda940038d830115be6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.7
|
Release files / touchdb-0.0.5-py3-none-any.whl
| Download URL | touchdb-0.0.5-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ad58b0fa8c30229acb0a97fb3e94b6854433f9f2e5efc4c841ba8df00c8f74c
|
|
BLAKE2b-256 checksum How to use checksums |
623ec02fbd1d5b6d09c70131e616715e93ec0448a3d04c4a2650d1d3d51248eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.7
|