You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

pydirdbjson

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pydirdbjson

A Database in JSON on directory

1.0.0
pipPyPI
Maintainers
1

Projeto-PyDirDbJson

Run Python tests Publish Python to PyPI GitHub repo size GitHub contributors GitHub stars GitHub forks

Project name is a Database in JSON on directory.

Prerequisites

No prerequisites

Installing PyDirDbJson

To install PyDirDbJson, follow these steps:

Windows, Linux and macOS:

pip install pydirdbjson

Using PyDirDbJson

To use pydirdbjson, follow these steps:

from pydirdbjson import Pydirdbjson
db = Pydirdbjson(db_path='my_database')

db.create_table(table_name='users')
db.insert(table_name='users',
          record_id='1',
          record={'name': 'John', 'age': 30, 'city': 'São Paulo'})
db.insert(table_name='users',
          record_id='2',
          record={'name': 'Mary', 'age': 25, 'city': 'Rio de Janeiro'})

db.create_table(table_name='customers')
db.insert(table_name='customers',
          record_id='1',
          record={'name': 'ABC'})
db.insert(table_name='customers',
          record_id='2',
          record={'name': 'XWZ'})

db.create_table(table_name='permissions')
db.insert(table_name='permissions',
          record_id='1',
          record={'user': '1', 'customer': '1'})
db.insert(table_name='permissions',
          record_id='2',
          record={'user': '1', 'customer': '2'})
db.insert(table_name='permissions',
          record_id='3',
          record={'user': '2', 'customer': '2'})
print(db.query(table_name='users', record_id='1'))

>>> {'name': 'John', 'age': 30, 'city': 'São Paulo'}

print(db.query_by_key_value(table_name='permissions',
                            key='customer',
                            value='1',
                            keys_to_return=['user']))

>>> [{'user': '1'}]
db.delete(table_name='users', record_id='1')

Database structure

|-- my_database
|   |-- users
|   |   |-- 1.json
|   |   |-- 2.json
|   |-- customers
|   |   |-- 1.json
|   |   |-- 2.json
|   |-- permissions
|   |   |-- 1.json
|   |   |-- 2.json
|   |   |-- 3.json

File structure

File: my_database/users/2.json

{"name": "Mary", "age": 25, "city": "Rio de Janeiro"}

Contributing to PyDirDbJson

To contribute to PyDirDbJson, follow these steps:

  • Fork this repository.
  • Create a branch: git checkout -b <branch_name>.
  • Make your changes and commit them: git commit -m '<commit_message>'
  • Push to the original branch: git push origin <project_name>/<location>
  • Create the pull request.

Alternatively see the GitHub documentation on creating a pull request.

Contributors

Thanks to the following people who have contributed to this project:

You might want to consider using something like the All Contributors specification and its emoji key.

Contact

If you want to contact me you can reach me at ricardo(dot)ferreras(at)gmail(dot)com.

License

This project uses the following license: MIT.

Keywords

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