Skip to main content

A Database in JSON on directory

Project description

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:

  1. Fork this repository.
  2. Create a branch: git checkout -b <branch_name>.
  3. Make your changes and commit them: git commit -m '<commit_message>'
  4. Push to the original branch: git push origin <project_name>/<location>
  5. 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.

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

pydirdbjson-1.0.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

pydirdbjson-1.0.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydirdbjson-1.0.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pydirdbjson-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7ceeeed34a8b58aff2ce5ea8f61a9548228bf6299c149ca771a7463e577011f2
MD5 7578cba799c526b8303d24c3bcd2a396
BLAKE2b-256 d40b6a4230e1f5dbded000de528607be13ce565c6ea42c3795a63a9905136e30

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydirdbjson-1.0.0.tar.gz:

Publisher: publish_to_pypi.yml on FerrerasRP/Projeto-PyDirDbJson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: pydirdbjson-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pydirdbjson-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e89285db8728b35576482dce93bf847dfded1ce852686f5d09d6240396ed96ad
MD5 0a80fd589dbcf878bdaf7a38f8f0ebdb
BLAKE2b-256 2d9df6ba1e05865d400200e41956426636849a8345b1466149020d97b644aa7c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydirdbjson-1.0.0-py3-none-any.whl:

Publisher: publish_to_pypi.yml on FerrerasRP/Projeto-PyDirDbJson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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