Socket
Book a DemoInstallSign in
Socket

pyezjson

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pyezjson

Easier Json Database For Python

pipPyPI
Version
1.0.0
Maintainers
1

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:

{}

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts