Skip to main content

Simple package to store JSON data more easily

Project description

database:

Simple package to store json data more easily !
No server and simple use !

from noserver_database import Database

database = Database('database-name', debug=True) # init noserver_database | debug on True will show errors but no raise them

# Create table

database.create_table('table-name')

# Get table

table = database.get_table('table-name')
# or
table = database > 'table-name'

# Add documents

table.insert_one({'message': 'hello world', 'author': 'armand@camponovo.xyz'})

# Find documents

documents = table.find({'query': 'value'}) # search in all documents and return a list of documents that have the key 'query' at the value 'value'
document = table.find_one({'query': 'value'}) # search in all documents and return the documents that have the key 'query' at the value 'value'
all_docs = table.find({}) # get all documents

# Delete documents

# for a simple doc:
document.delete()

# for a list of docs:

for to_delete_document in documents:
    # to_delete_document.delete()
    ... 

More documentation:

database.data.Database(self, name: str, folder: str = 'auto', debug: bool = False, do_not_create=False):

Methods:

create_table(self, name: str) create a table
get_table(self, name: str) get a database.table.Table() object
__gt__(self, name: str) get a database.table.Table() object

database.table.Table(self, name: str, super_: Database):

Methods:

raw_json_data(self) get a list off all documents (in json) in the table
insert_one(self, doc: dict) insert a document in the table
find_one(self, doc: dict) return a database.document.Document() object that have the values of doc equal to the values of the returned document
find(self, doc: dict) return a list of database.document.Document() object that have the values of doc equal to the values of the returned documents

database.document.Document(self, data: dict, super_: Database, table_children: Table):

Methods:

__getitem__(self) return the item of the dict asked
__del__(self) delete the document (this will return an error if you try document['item'] after that)

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

noserver_database-1.0.0.linux-x86_64.tar.gz (6.4 kB view details)

Uploaded Source

File details

Details for the file noserver_database-1.0.0.linux-x86_64.tar.gz.

File metadata

  • Download URL: noserver_database-1.0.0.linux-x86_64.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

File hashes

Hashes for noserver_database-1.0.0.linux-x86_64.tar.gz
Algorithm Hash digest
SHA256 dddfd7d265e33bcdd8dfec3c735006cc2ed82b35908fecc986f589723f899d33
MD5 b066e2f9d5d8beebab4019b72e9dcee2
BLAKE2b-256 0524fa82a7d24b4d3dd63756a9d41cf7c5ffe69c9f84843b460f4ee249ccff5f

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