MinuteDB is a simple local database written in Python that provides basic CRUD (Create, Read, Update, Delete) operations on a local file-based database.
Project description
MinuteDB
MinuteDB is a simple local database written in Python that provides basic CRUD (Create, Read, Update, Delete) operations on a local file-based database. It is designed to be lightweight and easy to use.
Installation
You can install MinuteDB using pip:
pip install minutedb
Usage
Importing MinuteDB
from minutedb import MinuteDB
Create an instance of MinuteDB
# Format:
db = MinuteDB(<table_name>, <primary_key>)
# Example:
db = MinuteDB("users", "name")
If the table already exist, then the primary key need not be specified.
# Format:
db = MinuteDB(<table_name>)
# Example:
db = MinuteDB("users")
Create items
# Format:
db.create_item({<primary_key>: <value>, <key1>: <value1>, <key2>: <value2>, ...})
# Example:
db.create_item({"name": "Alice", "age": 30, "height": 6.1})
db.create_item({"name": "Bob", "age": 20, "height": 5.7})
db.create_item({"name": "Eve", "age": 40, "height": 5.11})
Read an item
The read operation needs only the primary key to be specified.
# Format:
db.get_item(<primary_key>)
# Example:
db.get_item("Alice")
Update an item
The update operation needs the primary key as well as the updated key-value pair(s) in dictionaly format to be specified.
# Format:
db.update_item(<primary_key>, {<key>: <updated_value>})
# Example:
db.update_item("Alice", {"age": 31})
You can update multiple attributes also.
# Format:
db.update_item(<primary_key>, {<key1>: <updated_value1>, <key2>: <updated_value2>})
# Example:
db.update_item("Eve", {"age": 35, "height": 5.5})
You cannot update the value of the primary key itself.
Scan to find an item
The scan operation searches the items using key-value pair in dictionaly format. The search key must not contain the the primary key attribute. The return type will be a list of dictionaries.
# Format:
db.update_item({<key>: <value>})
# Example:
db.scan_item({"age": 40})
You can scan using multiple key-value pairs also.
# Format:
db.update_item({<key1>: <value1>, <key2>: <value2>})
# Example:
db.scan_item({"age": 20, "height": 5.7})
Delete an item
The delete operation deletes the item from the database using only the primary key.
# Format:
db.delete_item(<primary_key>)
# Example:
db.delete_item("Eve")
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 MinuteDB-0.0.2.tar.gz.
File metadata
- Download URL: MinuteDB-0.0.2.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b7580143cf315c8b610a9f5771cb1e6f2f0102886675ef960fa53326fa509ef
|
|
| MD5 |
acf2eedaf087cf264d448f23b7595ca9
|
|
| BLAKE2b-256 |
cacb26477300a4a772fe2c9b1a7326e4cba2f72387361d1cdf50e055ddfdeb9c
|
File details
Details for the file MinuteDB-0.0.2-py3-none-any.whl.
File metadata
- Download URL: MinuteDB-0.0.2-py3-none-any.whl
- Upload date:
- Size: 2.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cc3ccf13da532514e67e5e6769888fd47c4b91fd5e8c0c3f54977d1c8671f22
|
|
| MD5 |
e1b22ae2edaaefa93d8c302bec615e12
|
|
| BLAKE2b-256 |
145add480ea287de76145e4fbe8188c9249672cf6c51f3c8222a3d46f73a4e53
|