Giter Club home page Giter Club logo

pyezjson's Introduction

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

NOTE:

# You can install `ujson` for a better speed.
pip install ujson

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:

{}
"""

pyezjson's People

Contributors

m4hbod avatar parsapoorsh avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.