Skip to main content

Adelin Database

In many cases, we don't need a complex database infrastructure for the applications we want to build. In such situations, Adel is very suitable for creating a simple and manageable database.

Features

  • Written pure python
  • Save and load from file
  • You can automatically add a date and an ID number for each entered data.
  • The saved information, along with the Base64-encoded version in JSON format, is stored in .adl format.This way, it prevents ordinary users from tampering with and manipulating the JSON file.
  • Each saved piece of information is stored in .adl format under a folder with a name determined by you.

Install

pip install adelin

Usage

Init Data

from adelin import Makedata

# As a preliminary setup, we enter the row keys.
fruits = MakeData("Name","Price_USD","Units_KG","Color")

# Later on, we specify the name of the section under which we want to collect our data in our inherited object, and then we enter the values corresponding to the row keys.
# "Fruit" is our main heading.
fruits("Fruit", "Apple", 5, 200, "Red")
# Let's enter a new piece of data.
fruits("Fruit", "Apple", 4, 150, "Green")

# Now, the prepared data is ready to be saved.

Save and Read Data

# We complete the saving process by using the `save_db` method, where we first specify the folder name we want to save and then the file name.
# This way, we intend to establish a more organized recording system to prevent future complexity.
# The saved file is located under the "FRUITS" folder and is recorded in the "product.adl" file.
fruits.save_db("FRUITS","product")

# Reading operations can also be easily performed by using the `read_db` method, where you specify the folder and file you want to read from, following the same approach.
print(fruits.read_db("FRUITS","product"))
# Here is the result
{'Fruit': [{'Name': 'Apple', 'Price_USD': 5, 'Units_KG': 200, 'Color': 'Red'}, {'Name': 'Apple', 'Price_USD': 4, 'Units_KG': 150, 'Color': 'Green'}]}

Extra Features

Sometimes, we may want to add an ID number and a date to the data we want to enter. Let's now create the same example by adding an ID number and a Date.

fruits = MakeData("Name","Price_USD","Units_KG","Color", id=True, date=True)
fruits("Fruit", "Apple", 5, 200, "Red")
fruits("Fruit", "Apple", 4, 150, "Green")
fruits.save_db("FRUITS","product")    
print(fruits.read_db("FRUITS","product"))

Here is the result:

{'Fruit': [{'Name': 'Apple', 'Price_USD': 5, 'Units_KG': 200, 'Color': 'Red', 'Id': 'da8bcabb', 'Date': '26/09/2023'}, {'Name': 'Apple', 'Price_USD': 4, 'Units_KG': 150, 'Color': 'Green', 'Id': 'da8cc555', 'Date': '26/09/2023'}]}

Sometimes, we may prefer all entered headings to be in uppercase.

fruits = MakeData("Name","Price_USD","Units_KG","Color", column_up=True)
fruits("Fruit", "Apple", 5, 200, "Red")
fruits("Fruit", "Apple", 4, 150, "Green")
fruits.save_db("FRUITS","product")    
print(fruits.read_db("FRUITS","product"))
{'FRUIT': [{'Name': 'Apple', 'Price_USD': 5, 'Units_KG': 200, 'Color': 'Red'}, {'Name': 'Apple', 'Price_USD': 4, 'Units_KG': 150, 'Color': 'Green'}]}

Delete Data

In this current version, only data with entered ID numbers can be deleted, but this functionality can be further enhanced.

# The `del_with_id` method will delete the information of the data with the specified "xxx" ID number when provided with the folder name and the file name where the data with the "xxx" ID number is located.
fruits.del_with_id("FRUITS","product","c43c6881")

Fetch Data from File

You can obtain the data collected under each heading in a list format by entering the desired row values.

foods = MakeData("Name","Price_USD","Units_KG","Color", id=True, date=True, column_up=True)

foods("Fruit", "Apple", 5, 200, "Red")
foods("Fruit", "Apple", 4, 150, "Green")
foods.save_db("Fruits","product")

foods("xxVegetable", "cucumber", 2, 300, "Green")
foods("xxVegetable", "tomato", 1, 350," Red")
foods.save_db("Vegetables","salad")

foods("Eggs", "quail egg", 0.5, 750, "patchy brown")
foods("Eggs", "chicken egg", 0.1, 1800, "White")
foods("Eggs", "chicken egg", 0.1, 3200, "Brown")
foods.save_db("Eggs","eggs")

print(foods.read_db("Eggs","eggs"))

Result:

{'EGGS': [{'Name': 'quail egg', 'Price_USD': 0.5, 'Units_KG': 750, 'Color': 'patchy brown', 'Id': '60799066', 'Date': '26/09/2023'}, {'Name': 'chicken egg', 'Price_USD': 0.1, 'Units_KG': 1800, 'Color': 'White', 'Id': '60799067', 'Date': '26/09/2023'}, {'Name': 'chicken egg', 'Price_USD': 0.1, 'Units_KG': 3200, 'Color': 'Brown', 'Id': '6079b783', 'Date': '26/09/2023'}]}
print(foods.fetchdata("Vegetables","salad","xxVegetable","Name","Id"))
# result ['cucumber', 'd48fa160', 'tomato', 'd48fc737']

Metadata

Release files for adelin 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for adelin 0.1.1
File Size Uploaded Provenance Actions
adelin-0.1.1.tar.gz 6.7 kB Without provenance Details for adelin-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for adelin 0.1.1
File Interpreter ABI Platform Actions
adelin-0.1.1-py3-none-any.whl Python 3 none any Details for adelin-0.1.1-py3-none-any.whl

Total release size: 14.7 kB

Release files / adelin-0.1.1.tar.gz

Download URL adelin-0.1.1.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
396dd46d69d1159c296fa6a624f4570450c1ca1a01dda7c495e4d2a181b98113
BLAKE2b-256 checksum
How to use checksums
fc4d59451f68cc2d1e29a7c179e141f7c64117c02cf9bccd7b958fe5708d5c4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / adelin-0.1.1-py3-none-any.whl

Download URL adelin-0.1.1-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7f1214dc3404d284e999b07b168636ae2153fc7e98e39cdf0cdd504de74a05d4
BLAKE2b-256 checksum
How to use checksums
ab4b7ca351f9d4fda7cdb8e86ccd9beb1bf36edbae8dee3333512feddf22d2e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Security for adelin 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page