Skip to main content

Carol Python API and Tools

Project description

PyCarol

PyCarol is a Python SDK designed to support data ingestion and data access workflows on Carol. It provides abstractions for authentication, connector and staging management, data ingestion, and querying, enabling reliable integration with Carol services using Python. The SDK encapsulates low-level API communication and authentication logic, making data pipelines easier to build, maintain, and operate.

Table of Contents

Getting Started

Run pip install pycarol to install the latest stable version from PyPI. Documentation is hosted on Read the Docs.

Explicit authentication methods

Carol is the main object to access pyCarol and Carol APIs.

Using user/password

from pycarol import PwdAuth, Carol

carol = Carol(
    domain=TENANT_NAME,
    app_name=APP_NAME,
    auth=PwdAuth(USERNAME, PASSWORD),
    organization=ORGANIZATION
)

Using Tokens

from pycarol import PwdKeyAuth, Carol

carol = Carol(
    domain=TENANT_NAME,
    app_name=APP_NAME,
    auth=PwdKeyAuth(pwd_auth_token),
    organization=ORGANIZATION
)

Using API Key

from pycarol import ApiKeyAuth, Carol

carol = Carol(
    domain=DOMAIN,
    app_name=APP_NAME,
    auth=ApiKeyAuth(api_key=X_AUTH_KEY),
    connector_id=CONNECTORID,
    organization=ORGANIZATION
)

Setting up Carol entities

from pycarol import Connectors

connector_id = Connectors(carol).create(
    name="my_connector",
    label="connector_label"
)

Sending Data

from pycarol import Staging

Staging(carol).send_data(
    staging_name="my_stag",
    data=[{"name": "Rafael"}],
    connector_id=CONNECTORID
)

Reading data

from pycarol import BQ, Carol

BQ(Carol()).query("SELECT * FROM stg_connectorname_tablename")

Carol In Memory

from pycarol import Memory

memory = Memory()
memory.add("my_table", [{"id": 1}])
memory.query("SELECT * FROM my_table")

Logging

Prerequisites

Set LONGTASKID when running locally.

Logging messages to Carol

import logging
from pycarol import CarolHandler, Carol

logger = logging.getLogger(__name__)
logger.addHandler(CarolHandler(Carol()))
logger.info("Hello Carol")

Notes

  • Logs are linked to long tasks

  • Console fallback when task ID is missing

Calling Carol APIs

carol.call_api("v1/some/endpoint", method="POST")

Settings

from pycarol.apps import Apps
Apps(carol).get_settings(app_name="my_app")

Useful Functions

from pycarol.functions import track_tasks
track_tasks(carol, ["task1", "task2"])

Release process

  1. Open PR to main

  2. Merge after approval

  3. Update README if needed

Made with ❤ at TOTVS IDeIA

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycarol-2.56.11.tar.gz (118.5 kB view details)

Uploaded Source

Built Distribution

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

pycarol-2.56.11-py3-none-any.whl (136.3 kB view details)

Uploaded Python 3

File details

Details for the file pycarol-2.56.11.tar.gz.

File metadata

  • Download URL: pycarol-2.56.11.tar.gz
  • Upload date:
  • Size: 118.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for pycarol-2.56.11.tar.gz
Algorithm Hash digest
SHA256 1df7f1c55087b75ce6d22f2bd38c182b36f0c7c9cc7da14b2d4a8ecb5ed914d8
MD5 af25395d53839c4c2d19196087c653fe
BLAKE2b-256 9d853d09244037aebc1536643b120980c09a88e9b5dd5e9662fadcd1a160959d

See more details on using hashes here.

File details

Details for the file pycarol-2.56.11-py3-none-any.whl.

File metadata

  • Download URL: pycarol-2.56.11-py3-none-any.whl
  • Upload date:
  • Size: 136.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for pycarol-2.56.11-py3-none-any.whl
Algorithm Hash digest
SHA256 4ca1dbb4ac277ef042ee3d1e98082ca138aef2f3ebb17b65d37fea0676e7577c
MD5 02a3160f25f2978056d093a8e9e84593
BLAKE2b-256 a4dda6765cd57679f719dd0acd9f3569f97b4270ffb5c8e8ac4b3e654bcf21af

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