Skip to main content

Simple and lightweight document oriented database

Project description

LemonDB

Development Status: Beta

Simple ang lightweight document oriented database written in pure Python 3 (3.9)

Examples

Data insertion Example:

from lemondb import LemonDB
db = LemonDB('db')
db.insert({'name': 'John Doe'})

Query Example

LemonDB.Search can accept 3 types of parameters:

  • Standard Query class
  • Regular Expression
  • Lambda Functions
from lemondb import LemonDB
from lemondb import Query
db = LemonDB('db')
db.insert_many([
  {'name': 'John Doe'},
  {'name': 'Elizabeth Doe'}
])

data = db.search(query.name == 'John Doe')
print(data)
# Output: John Doe

#: Using lambda
data = db.search(lambda x: x['name'] == 'John Doe')
print(data)
# Output: John Doe

#: Using regular expression
data = db.search(
  query='^J(.*?)e$' #: Match when the first string is J and endswith e
)
print(data)
# Output: John Doe

Encrypted LemonDB

You can use Sidle Encryption within the LemonDB. Just use the SidleMiddleware and SidlePlugin

from lemondb import LemonDB
from lemondb.middleware import SidleMiddleware
from lemondb.plugin import SidlePlugin

db = LemonDB(
  name = 'sidle_db',
  middleware_cls = SidleMiddleware(password='password123'),
  plugin_cls = SidlePlugin
)

db.insert({'name': 'John Doe'})

Creating Middlewares & Plugins

By creating middleware, you need to use the base class lemondb.middleware.base.BaseMiddleware. The BaseMiddleware class handle all operation like read, write and delete. While plugins handle the initializing of the database operation and it is called whenever the LemonDB instance is initialized.

Just make sure to create a class based on the BaseClasses and inherit all functions, if the methods/functions are not inherited properly, it will throw an NotImplementedError.

Finally,you can call your custom middleware or plugin using the plugin_cls and middleware_cls parameter for the database. The default value is JsonMiddleware and LemonPlugin. Here is the example

from lemondb import LemonDB
from middleware import CustomMiddleware
from plugin import CustomPlugin

db = LemonDB(
  name='db.json',
  middleware_cls=CustomMiddleware,
  plugin_cls=CustomPlugin
)

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

lemondb-0.0.5.tar.gz (18.4 kB view details)

Uploaded Source

File details

Details for the file lemondb-0.0.5.tar.gz.

File metadata

  • Download URL: lemondb-0.0.5.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for lemondb-0.0.5.tar.gz
Algorithm Hash digest
SHA256 9b2c1a080271d5b446c5bc5d12dbde7227ea828e571e43b8cc1ddc261e848f62
MD5 3afeca4f1c5935fc33ce21c8edddfb78
BLAKE2b-256 53129cfef48a19dd48cd4e4b565e50230ba38ec193750130173ee7642ce0823b

See more details on using hashes here.

Supported by

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