Registry / http-networking / yandex-query-client

yandex-query-client

JSON →
library0.1.4pypypi✓ verified 23d ago

The `yandex-query-client` is the official Python HTTP client for Yandex Query, an interactive, fully managed service for running analytical and streaming queries on structured and semi-structured data using a common SQL dialect (YQL). The current version is 0.1.4, indicating it is an early-stage but actively maintained library. Its release cadence is currently irregular, consistent with a newer project.

pip install yandex-query-client --upgrade
INSTALL
IMPORT
SIG · YANDEX-QUERY-CLIEN
Y
yandex-query-client
http-networkingpythonv0.1.4
Install
8.2s avg
Import
388ms
Disk
168MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.408s · 167.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 8.2s · import 0.368s · 160MB
168MB installed
● package 168MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

YQHttpClient
from yandex_query_client import YQHttpClient
Primary client class for interacting with Yandex Query.
YQHttpClientConfig
from yandex_query_client import YQHttpClientConfig
Configuration class for the HTTP client, requiring IAM token and project ID.

This quickstart demonstrates how to initialize the Yandex Query client, create a simple SQL query, wait for its completion, and retrieve the results. It highlights the essential steps for basic interaction with the Yandex Query service. Ensure `YQ_IAM_TOKEN` and `YQ_FOLDER_ID` environment variables are set or replaced with actual values for authentication and operation within a specific Yandex Cloud folder.

import os from yandex_query_client import YQHttpClient, YQHttpClientConfig # --- Configuration --- # Replace with your Yandex Cloud IAM token and Folder ID. # It is recommended to use environment variables for sensitive credentials. IAM_TOKEN = os.environ.get('YQ_IAM_TOKEN', 'YOUR_IAM_TOKEN') PROJECT = os.environ.get('YQ_FOLDER_ID', 'YOUR_FOLDER_ID') if IAM_TOKEN == 'YOUR_IAM_TOKEN' or PROJECT == 'YOUR_FOLDER_ID': print("WARNING: Please set YQ_IAM_TOKEN and YQ_FOLDER_ID environment variables or replace placeholders.") # In a real application, you might raise an error or exit. exit("Missing Yandex Query credentials.") config = YQHttpClientConfig(IAM_TOKEN, PROJECT) client = YQHttpClient(config) # --- Example: Run a simple query --- query_text = "SELECT 777;" query_name = "my_sample_query" try: print(f"Creating query: '{query_text}' with name '{query_name}'...") query_id = client.create_query(query_text=query_text, name=query_name) print(f"Query created with ID: {query_id}") print(f"Waiting for query {query_id} to succeed...") # wait_query_to_succeed returns the number of result sets result_set_count = client.wait_query_to_succeed(query_id) print(f"Query {query_id} succeeded with {result_set_count} result set(s).") print(f"Fetching results for query {query_id}...") # get_query_all_result_sets fetches all result sets results = client.get_query_all_result_sets(query_id, result_set_count=result_set_count) for i, result_set in enumerate(results): print(f"\n--- Result Set {i+1} ---") # Access column names (if available) column_names = [col.name for col in result_set.columns] if result_set.columns else [] print(f"Columns: {column_names}") # Iterate through rows for row in result_set.rows: # Access values (example: assuming single column 'column0') # The exact structure of 'row' might vary, often it's a list/tuple of values print(f"Row: {row}") except Exception as e: print(f"An error occurred: {e}")
Debug
Known issues
gotchaAuthentication requires a valid Yandex Cloud IAM token and a specific Folder ID. IAM tokens have an expiration period, which can cause authentication failures for long-running processes if not refreshed. Ensure your application handles token renewal or uses a service account key for persistent access.
fix
Store IAM token and Folder ID in environment variables (`YQ_IAM_TOKEN`, `YQ_FOLDER_ID`). Implement logic to refresh IAM tokens if using temporary credentials, or configure service accounts with appropriate roles (e.g., `yq.editor`) for automated access.
affects: 0.1.x
gotchaThe library is in an early development stage (version 0.1.x). While official, minor version updates may introduce API changes or breaking modifications without a major version increment (e.g., a 0.2.0 release might contain breaking changes).
fix
Always pin the exact version (`yandex-query-client==0.1.4`) in production environments and thoroughly test updates before deployment. Refer to the GitHub repository's `CHANGELOG.md` (if available) or commit history for specific changes between versions.
affects: 0.1.x
gotchaYandex Query uses YQL, a specific SQL dialect, which may have differences from standard SQL implementations. Queries written for other SQL databases might require adjustments to work correctly with Yandex Query.
fix
Consult the Yandex Query Language (YQL) documentation for syntax and feature specifics when constructing queries. Test your YQL queries directly in the Yandex Cloud console before integrating them into your application if you encounter unexpected behavior.
affects: 0.1.x
Upgrade
Version history
0.1.4latest on PyPI · released May 10, 2024
Audit
Dependencies
pythonrequiredRequires Python 3.8 or higher.
Agent activity
23 hits · last 30 days
node
18
OpenAI (training)
1
Resources
yandex-query-client — pip install yandex-query-client · libregistry