Simple json database
Project description
Py-Simple-DB
Install:
pip install PySimpleDB
Load:
from PySimpleDB import DataBase
mydb = DataBase("simple.bd")
mydb_unique = DataBase("unique.bd", unique="user")
You can use a database in which the unique key will be a number, or specify your own name for the unique key, which will need to be transmitted
Add row:
This command automatically saves the state of the database.
mydb.add(name="Hello", last_name="world", gender="male") # any values
mydb_unique.add(user="User1", name="Hello world", gender="male") # any values
# ^ unique key
Make sure you are passing in a unique key for the appropriate database.
As in this example, the unique key is the "user" argument specified during initialization.
Find:
Returns the id of the first matched element, or an array of ids.
id_first = mydb.find(name="Hello") # 0
id_array = mydb.find_all(gender="male") # [0...]
id_first_unique = mydb_unique.find(gender="male") # "User1"
id_array_unique = mydb_unique.find_all(gender="male") # ["User1"...]
Get row:
Returns value by id.
mydb.get(id_first) # {"name": "Hello", "last_name": "world", "gender": "male"}
mydb_unique.get(id_first_unique) # {"name": "Hello world", "gender": "male"}
Delete row:
This command automatically saves the state of the database.
mydb.delete(id_first)
mydb_unique.delete(id_first_unique)
Save:
mydb.save()
Get All Data:
Allows you to get the whole database.
mydb.get_all()
or
mydb.data
You can also see usage examples here
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
PySimpleDB-0.2.0.tar.gz
(2.5 kB
view hashes)
Built Distribution
Close
Hashes for PySimpleDB-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5755edbdfdae78ab2d96bacfa69f3931afb17103b19c190c2dcf33a403f07b1 |
|
MD5 | 75471b8e03a2f6857b67800ae84baf5e |
|
BLAKE2b-256 | 858ef2a36f6c25ee7c100b011afa040973f65dae8c63e6c5f5a53931a5225d84 |