Skip to main content

AetherDB is a lightweight document-like database for Python.

Project description

AetherDB

AetherDB is a simple lightweight db stored entirely inside json files and folders. AetherDB is document-like based db, but rather than storing each document as separate json it stores all documents inside json clusters. Data stored in following format:

cluster_0.json
{
    "document_id": {
        "key1": "value1",
        "key2": "value2",
        ...
    }
}

Any data type supported by json can be stored.

Installation

pip install aetherdb

Usage

To open db you simply need to create db class instance, specifying path to your db folder. If folder (or folders) in path does not exists they will be created.

from aetherdb import DB
db = DB("path_to_your_DB_folder")

After that you can do all kinds of operations on your DB by calling created class instance`s methods.

# Open sub db (create if there is no such sub db)
db.open_sub_db("sub_db_name")
# Create sub db
db.create_sub_db("sub_db_name")
# Delete sub db
db.delete_sub_db("sub_db_name")
# Write butch of data
db.write({"document_id" : { some_data }})
# Read data by document id
db.read("document_id")
# Update data by id
db.update("document_id", { new_data })
# Delete data by id
db.delete("document_id")
# Backup db
db.backup("path_to_where_backup_should_be_stored")
# Make query request to db
db.query("query_text")

Query syntax

Query supports a fixed list of requests:

  • selectById{}
  • selectByIdRegex{}
  • selectWhere{}
  • selectWhereRegex{}
  • withDB{}
  • createDB{}
  • deleteSelection{}
  • delete{}
  • update{}
  • insert{}
  • withParentDB{}
  • filter{}
  • backup{}
  • return{} Requests can be chained using ".", for example:
selectById{"id"}.return{}

All requests should have {}, even if they dont need any data. Data needed for request can be passed inside {}. Each request require some set of data to function.

Selectors

Selectors will select data from db by some specified data like document id. Selected data will be saved until query will be completed, but will not be returnd unless specified by other requests.

selectById

Requires string containig document id to search in db.

selectById{"some_document_id"}

selectByIdRegex

Requires regular expression to match document ids and returns all data with document ids matching given regular expression.

# This request will select every possible document
selectByIdRegex{".*"}

selectWhere

Requires comma separated key-value pairs in format key=value to search data with same key-value pairs.

selectWhere{"key1=value1,key2=value2"}

selectWhereRegex

Requires comma separated key-value pairs in format key=value to search data with same key-value pairs. Values can be regular expressions to match.

selectWhereRegex{"key1=.*,key2=value2"}

withDB

Requires sub db name. Will open sub db and pass all requests after this request to sub db. Will return averything that sub db will return.

withDB{"sub_db_name"}

createDB

Requires sub db name. Will create sub db with specified name.

createDB{"sub_db_name"}

deleteSelection

Does not require any input. Will delete all data selected by previous requests from db.

deleteSelection{}

delete

Requires document id. Will delete document with specified id from db.

delete{}

update

Requires document id and data to write in document separated by comma. Will update data written in document with specified id to specified data.

update{"document_id,{'key1':'value1','key2':'value2'}"}

insert

Requires data to write to db. Data should be in following format:

{
    "document_id": {
        "key1": "value1",
        "key2": "value2",
        ...
    }
}

Data will be added to db.

insert{"{'document_id':{'key1':'value1','key2':'value2',...}}"}

withParentDB

Does not require any input. Will open db in which this sub db is located and pass all requests after this request to it. If used inside root db will do nothing (Will work only after withDB). Will return anything everything that opened db will return.

withParentDB{}

filter

Requires comma separated key-value pairs in format key=value. Will filter out all data selected by previous requests and leave in result only data that will match key-value pairs.

filter{"key1=value1,key2=value2"}

backup

Require optional path to where backup should be stored. Will create zip containing backup of current db at specified location. If path not specified backup will be created inside db in backup folder.

backup{"path_to_backup_folder"}

return

Does not require any input. Will return all data selected by previous requests. After this request query will finish, other requests after this will be ignored.

return{}

Contribution

Pull requests will be mostly ignored for now unless they fix some security issues. Please specify what and how your changes will fix.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aetherdb-0.0.1b1.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aetherdb-0.0.1b1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file aetherdb-0.0.1b1.tar.gz.

File metadata

  • Download URL: aetherdb-0.0.1b1.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for aetherdb-0.0.1b1.tar.gz
Algorithm Hash digest
SHA256 1d937e8f92f8ae49885a6325985c98db544fcd1783bfae6b78ca4a8a059b2175
MD5 18b4643a6ee30fb43d862adace623fc7
BLAKE2b-256 33a28bcf64e5350d412f7b2f1ba0a2dc5301b01d06e67060e3a747267384bbb7

See more details on using hashes here.

File details

Details for the file aetherdb-0.0.1b1-py3-none-any.whl.

File metadata

  • Download URL: aetherdb-0.0.1b1-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for aetherdb-0.0.1b1-py3-none-any.whl
Algorithm Hash digest
SHA256 85b54f74e8adb673690013481065009424a9ea5f1a27d31c51e6388fa02bc5cd
MD5 45a0ff0399d3db78bd8efdb3b8dc75a6
BLAKE2b-256 650906c94562be89f0cbfd5717fdeaadc78ec3006dc7ca1be2b65cb3c9ef2e06

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page