Skip to main content

Python wrapper for aijsondb

Project description

Python bindings for aijsondb

The idea behind aijsondb is rather simple:

  • Use a single json data file as data source.
  • Declare the content of json data with json schema.
  • Query the data with a JavaScript expression.

Writing a JavaScript expression to query a json data is not very convenient for humans. On the other hand letting an LLM creating the JavaScript expression using the json schema works well.

Thus using aijsondb in an agentic workflow is a good option to "talk with data".

Python package aijsondb is only a wrapper for the aijsondb library.

Installation

aijsondb is available for Linux and Windows.

Supported Python versions: Python 3.7 and above are recommended.

pip install aijsondbpy

Usage

Import the package.

import aijsondb

Load and validate the json data into an in memory data structure.

path_data="data/500 KB_V2.json"
path_schema="data/employeeSchemaDescription_V2.json"
aijsondb.init_db(path_data,path_schema)

Now you can query the data.

res=aijsondb.query_data_javascript("var result=data.employees.length;")
print(res)

By convention the root json object is accessible as data in the query. Also, the result of the query must be stored in the variable result.

The return value is a JSON string containing the result.

Sample data are available on aijsondb.

Python script test_agent.py shows you how to create an langchain agent to talk with your JSON data in python using the aijsonpy package.

Sample json data

The file 500_KB_V2.json in the data folder is derived from the dataset "Employees { 10 } Level Nested Formatted Versions", specifically the "500 KB 10 Level Formatted" variant available at page.

The files test.json and 500_KB_V2Err.json are also based on this dataset.

The JSON schema employeeSchemaDescription_V2.json was automatically generated from 500_KB_V2.json and subsequently edited by hand.

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

aijsondbpy-0.10.0.tar.gz (2.8 MB view details)

Uploaded Source

Built Distribution

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

aijsondbpy-0.10.0-py3-none-any.whl (2.9 MB view details)

Uploaded Python 3

File details

Details for the file aijsondbpy-0.10.0.tar.gz.

File metadata

  • Download URL: aijsondbpy-0.10.0.tar.gz
  • Upload date:
  • Size: 2.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for aijsondbpy-0.10.0.tar.gz
Algorithm Hash digest
SHA256 d59240ba318181ef6bd86841dff1454c2ea4cf983d51b1cc20018fa328c76414
MD5 35782c16d60834dd8951364a3d116133
BLAKE2b-256 0205db47e6d81644630ef5668184ac9b7481d2b71330eb9d72a9d3e634c16246

See more details on using hashes here.

File details

Details for the file aijsondbpy-0.10.0-py3-none-any.whl.

File metadata

  • Download URL: aijsondbpy-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for aijsondbpy-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85b36ecb0a7fcc502e7ab12401630f87d88f0ccdb8781e5b3ecab6e7ffd341df
MD5 cc0024fb8dc05d2985a68118d6b3f3af
BLAKE2b-256 a859263057ae609e5ee32a016158e083ddaeea3f69f58f418032f6f1c9f449d8

See more details on using hashes here.

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