Skip to main content

A very easy database but very good :)

Project description

EasyDB

a simple python local database

Documentation

to get started in an easy way... let's start by creating a new instance of the Data Base

Get Start

Create Objects

Delete Objects

Filtering Objects

Find Objects

Get Objects

Save Database

Load Json

from EasyDB import EasyDB, DB

db = EasyDB(autoSave=True)
collection: DB = db.newCollection

what is "autoSave" of the DB instance?

it is an automatic backup method, which you can activate or deactivate... having this system activated... your database is less vulnerable to a total loss of data, in case something unforeseen occurs

Creating Objects In The Database

You can see some examples on: Create Items

for you to create objects in the database, it is also very easy... see below

collection.create("hello", "word")

Just that? ya

it is worth noting. To create objects in the database in a specific way you can do:

collection.create("hello", {})
collection.create("how are you?","good, and you?", "hello")
{
  "hello": {
    "how are you?": "good, and you?"
  }
}

the path must be divided by dots

collection.create("hello", {})
collection.create("how are you?", {}, "hello")
collection.create("good, and you?", "me also", "hello.how are you?")

Deleting Objects

You can see some examples on: Delete Items

to delete an object you just use the .delete method. see below

collection.delete("path")

Filtering objects

You can see some examples on: Filtering Items

To get start filtering objects, you must create a filter, lambda or a normal def

def filter(arg): #receive a db object
  #your stuff, but must return a bool
  return arg == 1
  
 #or
 
filter = lambda x: x == 1
 

and then, call

for i in collection.filter(filter):
  print(i.path, i.value)

Attributes

filtering method returns 2 attributes. path and value

value return the value what returns True path return the path of the value ("path.to.value")

Find objects

You can see some examples on: Finding Items

Find item is like the filtering method... but returns only one value

result = collection.find(filter)
print(result.path, result.value)

Get object

You can see some examples on: Getting Items

To get a item, you can just type:

print(collection.get(path if has))

Save database

You can see some examples on: Save Database

to save your database, you jsut type

collection.save()

Load json

You can see some examples on: Load Json

to load you json file to db you just type

collection.load("<path> or <file stream>", mode="set"| "append" )

Modes

apppend: append data to database

set: sets the data from de json as database

Miscs

if autoSave is off... you can store any type of object. however when trying to save, it will corrupt your database

Progres

  • sync and local db
  • load modes
  • async DB

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

EasyDB.py-1.2.8-py3.11-linux-x86_64.egg (126.9 kB view hashes)

Uploaded Source

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