Skip to main content

A simple nosql json storage for small projects.

Project description

project

Looking for contributions.

What ?

really simple no-sql database ( for small projects ) using json.

Documentation

read the docs.md file.

Quickstart ( simple example )

from posql_simple import w_out_sql.py
my_password = "hello world" # for cipher coding ( key )
path = "./default.pst"      # use the pst extension
my_db = Database (__pass =  password, path = path)
my_collection_name = "clients"
my_collection = Collection ( collect_name = my_collection_name) # creating the collection
db.bind_new_collection(my_collection) # binding the collection to the db

client1 = {
    "name" : "hello world"
}
my_collection.add_record( client1 )  # adding a record to the collection
db.save()                            # saving ( writes data to the file )

Documentation

Database ( class )

init method requires pass ( for encrypting and decrypting ), optionally a dict full of collections, and the path of the file ( where to store the content ).

save method is saving the data in the file, takes one positional argument for debuging purpose ( default value : True ).

load returns a Database object. The arguments are path ( the path of the file ) and the decrypt_pass. Throws FileNotFoundError err if the file doesn't exist and ( or ) InvalidFileExtensionError ( if the file extension doesn't match the .pst ).

bind_new_collection binds the collection to the database object ( for data persistence ). Takes a collection as Param.

get_collection returns a collection object. Args : coll_name ( name of the collection ). get_collections returns a dict with all the collections.

Collection

init method requires a name ( collect_name ), and a list of the json records ( the data persisted ) which is optinal.

add_record method takes one positional argument which is the json obj that you want to store. Returns a boolean ( True, if the transaction is OK, and false if it's not ok ). Each object is padded with the "_id" entry ( uuid generated string ). You can add your own custom "_id" entry.

delete_by_id method takes one positional param which is the id ( making a linear search ). Like the add_record method, it returns a boolean.

find_by_id same as delete_by_id ; returning deep copy of the dict ( avoid mutability ) or else None.

update_obj : takes two positional args : new_obj ( the obj to persist, must contain an "_id" entry , or else throwing an error ), returning a bool.

search_by : takes two positional args : slot_name which is the name of the entry you want ( for instance the "name" entry of, each dict ) and the slot_value. Returns None if not found.

get_all_slot : returns a list of all the entries.

this lib supports multithreading queries by using synchronization.

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

poslq_simple-0.2.1.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

poslq_simple-0.2.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file poslq_simple-0.2.1.tar.gz.

File metadata

  • Download URL: poslq_simple-0.2.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for poslq_simple-0.2.1.tar.gz
Algorithm Hash digest
SHA256 4f2df3842733e27826634df227e5d7ca469823db00aca94ea6311e12f06d2b92
MD5 ce1157907908520df2388a792f633bbd
BLAKE2b-256 6eb562aef4873bf93af2351f88b388285ec8eec2fea14d6d62817073e7d3c16c

See more details on using hashes here.

File details

Details for the file poslq_simple-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: poslq_simple-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for poslq_simple-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 defac8e7a1449c129cc88a50862382f073dec6ba0e0a008c0dd4278856fe1d10
MD5 ac4cf4c702f529941f96e6f35ff80ea9
BLAKE2b-256 9993ce5060c65d14fbbb3be4b53596e22342d75bb821cd2db5f5084eca13d2bf

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