Skip to main content

Python Ragic API client for data loading and manipulation.

Project description

Python Ragic

A Python client for interacting with the Ragic API. This library simplifies making requests to Ragic databases, handling authentication, and working with records.

PyPI Downloads


Table of Contents


Features

  • Easy authentication and connection setup
  • Read data from Ragic databases

Getting Started

  1. Get your API key from Ragic. link

    1.1. Add environment variables to .env file:

    • RAGIC_URL
    • RAGIC_NAMESPACE
    • RAGIC_API_KEY
  2. Setup structure.yaml.

    2.1. Follow the structure file to define the structure of your database.

    2.2. Retrieve the field id from Ragic. link

  3. Install the package using pip:

    pip install python-ragic
    

Code Snippets

Load Data (Table-level)

from ragic import RagicAPIClient

client = RagicAPIClient(
    base_url=None,
    namespace=None,
    api_key=None,
    version=3,
    structure_path="structure.yaml",
)

TAB_NAME = "Sales Management System"
TABLE_NAME = "customer"

data_dict = client.load(
    TAB_NAME,
    TABLE_NAME,
    conditions=[("gender", OperandType.EQUALS, "Male")],
    offset=0,
    size=10,
    other_get_params=OtherGETParameters(subtables=False, listing=False),
    ordering=Ordering(order_by="customer_id", order=OrderingType.ASC),
)

if data_dict:
    with open("data.json", "w", encoding="utf-8") as f:
        f.write(json.dump(data_dict, f, indent=4))
else:
    print("No data found.")

Write new data to Ragic database

from ragic import RagicAPIClient

client = RagicAPIClient(
    base_url=None,
    namespace=None,
    api_key=None,
    version=3,
    structure_path="structure.yaml",
)

TAB_NAME = "Sales Management System"
TABLE_NAME = "customer"

data_dict = {
    "Name": "John Doe",
    "Age Group": "41 - 50",
    "Race": "Chinese
}

resp_dict = client.write_new_data(
    TAB_NAME, TABLE_NAME, data=data_dict
)
if resp_dict:
    with open("write_response.json", "w", encoding="utf-8") as f:
        f.write(json.dump(resp_dict, f, indent=4))
    print("Record created successfully.")
else:
    print("Failed to create record.")

Modify Data (single record)

from ragic import RagicAPIClient

client = RagicAPIClient(
    base_url=None,
    namespace=None,
    api_key=None,
    version=3,
    structure_path="structure.yaml",
)

TAB_NAME = "Sales Management System"
TABLE_NAME = "customer"

data_dict = {
    "Name": "John Doe",
    "Age Group": "41 - 50",
    "Race": "Chinese"
}
record_id = "<ragicId>"  # Replace with the actual record ID

resp_dict = client.modify_data(
    TAB_NAME,
    TABLE_NAME,
    data=data_dict,
    record_id=record_id
)

Delete Data (single record)

from ragic import RagicAPIClient
client = RagicAPIClient(
    base_url=None,
    namespace=None,
    api_key=None,
    version=3,
    structure_path="structure.yaml",
)

TAB_NAME = "Sales Management System"
TABLE_NAME = "customer"

record_id = "<ragicId>"  # Replace with the actual record ID

resp_dict = client.delete_data(
    TAB_NAME,
    TABLE_NAME,
    record_id=record_id
)

Get Data (single record)

from ragic import RagicAPIClient
client = RagicAPIClient(
    base_url=None,
    namespace=None,
    api_key=None,
    version=3,
    structure_path="structure.yaml",
)

TAB_NAME = "Sales Management System"
TABLE_NAME = "customer"

record_id = "<ragicId>"  # Replace with the actual record ID

resp_dict = client.get_data(
    TAB_NAME,
    TABLE_NAME,
    record_id=record_id
)

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

python_ragic-0.2.tar.gz (21.2 kB view details)

Uploaded Source

Built Distribution

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

python_ragic-0.2-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file python_ragic-0.2.tar.gz.

File metadata

  • Download URL: python_ragic-0.2.tar.gz
  • Upload date:
  • Size: 21.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.11

File hashes

Hashes for python_ragic-0.2.tar.gz
Algorithm Hash digest
SHA256 639a1480b17a627b60a03969f7b85d2a069df73b8845fdc34534bfafcb08894a
MD5 4b41704266a1f13c0325067de15c7bd4
BLAKE2b-256 48215cbde60b82b022d156c619f78ed7ca92505190a86a905a6ad9cdbff88d86

See more details on using hashes here.

File details

Details for the file python_ragic-0.2-py3-none-any.whl.

File metadata

  • Download URL: python_ragic-0.2-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.11

File hashes

Hashes for python_ragic-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e3d11ff189c6190244110225d3b101a5a1ab93f82112c93884f4b589c617564c
MD5 f49cc522b637bf18c78d24101dae2d1c
BLAKE2b-256 955b1965d279248473d285917d3e637811002169765247f3e843d9ceef09cbd7

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