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.
Table of Contents
Features
- Easy authentication and connection setup
- Read data from Ragic databases
Getting Started
-
Get your API key from Ragic. link
1.1. Add environment variables to
.envfile:RAGIC_URLRAGIC_NAMESPACERAGIC_API_KEY
-
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
-
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_ragic-0.3.tar.gz.
File metadata
- Download URL: python_ragic-0.3.tar.gz
- Upload date:
- Size: 22.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
984efbe367c054ee2eaecca7d06b35506035125bd7db395c08ee6f8bdbc95985
|
|
| MD5 |
64e442ee4c885ac542f2168b532888de
|
|
| BLAKE2b-256 |
8575239a19a494e4ffd7420ed3e5faba96e9f7b59b8641dc9540027b0d8af863
|
File details
Details for the file python_ragic-0.3-py3-none-any.whl.
File metadata
- Download URL: python_ragic-0.3-py3-none-any.whl
- Upload date:
- Size: 23.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bf3418adc7fe8d795c8d44b3813df4e4ae19d4c0f223faefb2e2228a86b93e2
|
|
| MD5 |
5b6c08377f7b67858da950cdf602259d
|
|
| BLAKE2b-256 |
943d1eeb7688f4f88a7caa2397ad2c2792445c7a1bf53b01f8eb164c858b5af8
|