Skip to main content

A small database using json

Project description

PyDbJson

pydbjson is a simple Python library for managing JSON-based databases.

Table of Contents

Installation

You can install pydbjson using pip:

pip install pydbjson

Description

pydbjson provides a convenient way to interact with JSON-based databases in Python. It allows you to load data from a JSON file, insert, retrieve, delete, and find documents, and save the data back to the file.

Usage

Importing the library

from pydbjson import pydbjson

Creating an instance of pydbjson

db = pydbjson("database.json")

Create an instance of the pydbjson class by providing the filename or path of the JSON database file.

Inserting a document

document = {"name": "John", "age": 30}

key = db.insert_one(document)

Insert a document into the database. The insert_one method returns the key of the inserted document.

Find a document

document = {"name": "John"}

found_document = db.find_one(document)

Find a document from the database based on the provided data.

Deleting a document

db.delete_one(found_document)

Delete a document from the database based on the data.

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

pydbjson-0.0.2.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

pydbjson-0.0.2-py3-none-any.whl (3.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page