Skip to main content

datart-client

A reusable, thread-safe Python client for querying Datart.

Configuration is fully injected via constructor arguments — the client does not depend on any host project's global config module, so it can be reused across projects.

Features

  • Log in to Datart and obtain a token (auto re-login on HTTP 401)
  • Run SQL queries and get results as a pandas DataFrame, a raw dict, or Excel bytes
  • Preconfigured data sources plus dynamic discovery of Datart data sources
  • HTTP proxy and SOCKS5 proxy support
  • Thread-safe (a reentrant lock guards shared state)
  • A fresh requests.Session per request (avoids cross-thread connection-pool issues)

Installation

pip install datart-client

SOCKS5 proxy support is optional:

pip install "datart-client[socks]"

Quick start

from datart_client import DataArtist

artist = DataArtist(
    username="your_username",
    password="your_password",
    login_url="https://your-datart-host/api/v1/users/login",
    query_url="https://your-datart-host/api/v1/data-provider/execute/test",
    # Optional: enable dynamic data-source discovery
    source_url="https://your-datart-host/api/v1/sources",
    org_id="your_org_id",
    # Optional: preconfigured data sources
    sources=[
        {"name": "example_mysql", "id": "source-id-1", "db_type": "mysql"},
        {"name": "example_oracle", "id": "source-id-2", "db_type": "oracle"},
    ],
    # Optional proxies
    http_proxies=None,   # e.g. {"http": "...", "https": "..."}
    socks5=None,         # e.g. {"ip": "127.0.0.1", "port": 1080}
)

df = artist.query("select 1", source_name="example_mysql", result_type="df")

API

DataArtist(username, password, login_url, query_url, source_url=None, org_id=None, sources=None, http_proxies=None, socks5=None)

Create a client. Only username, password, login_url and query_url are required; everything else is optional.

  • source_url, org_id — enable dynamic data-source discovery via get_sources().
  • sources — preconfigured data sources; accepts a list of {"name", "id", "db_type"} dicts, or a legacy {name: id} mapping.
  • http_proxies — a requests-style proxies dict.
  • socks5{"ip", "port"}; enabling this installs a process-wide SOCKS5 proxy.

query(statement, source_name, size=1000000, result_type="df")

Run a SQL statement against the named data source.

  • source_name is resolved against preconfigured sources first, then discovered ones.
  • result_type:
    • "df" — a pandas DataFrame (default)
    • "raw" — the raw response dict
    • "excel".xlsx file content as bytes

get_sources()

Discover available JDBC data sources from Datart (requires source_url and org_id). Results are cached on the instance.

Requirements

  • Python >= 3.8
  • requests, pandas, xlsxwriter
  • PySocks (only when using the socks5 option; installed via the socks extra)

License

MIT

Download files

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

Source Distribution

datart_client-1.0.3.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

datart_client-1.0.3-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file datart_client-1.0.3.tar.gz.

File metadata

  • Download URL: datart_client-1.0.3.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for datart_client-1.0.3.tar.gz
Algorithm Hash digest
SHA256 327bde6da8a02bb7bd5ebafddb72d565debd25bd4248ab2319c057e56a1ee2f8
MD5 3c942ff09f9ee082765cdf7d68c7ce9d
BLAKE2b-256 f2edf865fa0165b37d4f5ac6a4a2e7a5bc1ae3efdce2a8fb23233ce06e7643ee

See more details on using hashes here.

File details

Details for the file datart_client-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: datart_client-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for datart_client-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d80c27a356868325aa5b51dd43d707a8177d00c6558abb6497db82b241ddd495
MD5 7c62d59f877f145ae61d80982d669d18
BLAKE2b-256 967003f917518019db8fb176dadc989496eeb87e9214e60e81a019fc64ad45ba

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page