Skip to main content

Easier Json Database For Python

Project description

Easy Json Database

pyezjson
Easier Json Database For Python

Installation

Easy Way

pip install pyezjson

Less Easy Way

pip install git+https://github.com/M4hbod/pyezjson.git

Usage

Connect:

from pyezjson import connect

mydb = connect('my_database.json', indent=4)

Add:

mydb.add(False, 'users', 'user_1', first_name='Lee', last_name='Everet')

# `False` is for `update_if_exist` argument

"""
Result in my_database.json:

{
    "users": {
        "user_1": {
            "first_name": "Lee",
            "last_name": "Everet"
        }
    }
}
"""

Update:

mydb.update(False, 'users', 'user_1', 'last_name', SELF='Everett')

# If you use `SELF`, it will update it for the last argument
# You can also use `SELF` in `add` function 
# `False` is for `add_if_not_exist` argument

"""
Result in my_database.json:

{
    "users": {
        "user_1": {
            "first_name": "Lee",
            "last_name": "Everett"
        }
    }
}
"""

Delete:

mydb.delete('users', 'user_1', 'last_name')

"""
Result in my_database.json:

{
    "users": {
        "user_1": {
            "first_name": "Lee"
        }
    }
}

Check:

result_first_name = mydb.check('users', 'user_1', 'first_name')
result_last_name = mydb.check('users', 'user_1', 'last_name')

print(result_first_name)
print(result_last_name)

"""
Result:

>>> True
>>> False
"""

Get:

data = mydb.get('users', 'user_1')
print(data)

"""
Result:

>>> {'first_name': 'Lee'}
"""

Get The Whole Database:

data = mydb.get_all()
print(data)

"""
Result:

>>> {'users': {'user_1': {'first_name': 'Lee'}}}
"""

Reset:

mydb.reset()

"""
Result in my_database.json:

{}

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

pyezjson-1.0.0.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

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

pyezjson-1.0.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file pyezjson-1.0.0.tar.gz.

File metadata

  • Download URL: pyezjson-1.0.0.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for pyezjson-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1b0a8277fa821fc72b404b04184919ae7bf997cece072c9ca18510b584f9f718
MD5 0f1eb6a8ecb1ab595966aa00a5962cd5
BLAKE2b-256 d524ec024974bb1d04b41606a56627bd287b491b076cf4bfaa9136c20842f3dd

See more details on using hashes here.

File details

Details for the file pyezjson-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyezjson-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for pyezjson-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8744250fbf8866c42beb9909fcab7ff9a1dd91a833a94efba41cf0bd6720b3c6
MD5 d8e98b8d75909c3b7fd657cb1be983fe
BLAKE2b-256 532e1f57ac7e7db7f8bda407e9ca058c9e81c9b6aa3801d8f3680573d331910d

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