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 rawdict, 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.Sessionper 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 viaget_sources().sources— preconfigured data sources; accepts a list of{"name", "id", "db_type"}dicts, or a legacy{name: id}mapping.http_proxies— arequests-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_nameis resolved against preconfigured sources first, then discovered ones.result_type:"df"— a pandasDataFrame(default)"raw"— the raw responsedict"excel"—.xlsxfile 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,xlsxwriterPySocks(only when using thesocks5option; installed via thesocksextra)
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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
327bde6da8a02bb7bd5ebafddb72d565debd25bd4248ab2319c057e56a1ee2f8
|
|
| MD5 |
3c942ff09f9ee082765cdf7d68c7ce9d
|
|
| BLAKE2b-256 |
f2edf865fa0165b37d4f5ac6a4a2e7a5bc1ae3efdce2a8fb23233ce06e7643ee
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d80c27a356868325aa5b51dd43d707a8177d00c6558abb6497db82b241ddd495
|
|
| MD5 |
7c62d59f877f145ae61d80982d669d18
|
|
| BLAKE2b-256 |
967003f917518019db8fb176dadc989496eeb87e9214e60e81a019fc64ad45ba
|