Skip to main content

QAPI SDK provides a library of classes for working with Query API in your Python code.

Project description

QAPI SDK

QAPI SDK provides a library of classes for working with Query API in your Python code.

Requirements

* Python 3.6+

Installation

pip install qapi-sdk 

Environment Variables

  • QAPI_URL: QAPI API URL
  • EMAIL: Your email

Examples

Query

  • FEED ID: The table must exist in Athena.
  • QUERY ID: The query id is used as an identifier for the query. Query id must be unique. Once you have retrieved your data from S3 it is advised to delete the query.
  • SQL: The SQL query to be executed.
import time

from dotenv import load_dotenv

from qapi_sdk import Query

load_dotenv()

# Step 1: Assign your FEED ID, QUERY ID, and SQL QUERY
feed_id = "[FEED/TABLE NAME]"
query_id = "[QUERY NAME]"
query = f"SELECT * FROM {feed_id}"

# Step 2: Create a Query object
my_query = Query(
    feed_id=feed_id,
    query_id=query_id
)

# Step 3: Execute the query push
my_query.push_query(sql=query)

# Step 4: Wait for the query to complete
while my_query.query_status():
    print("Waiting for query to complete...")
    time.sleep(10)

# Step 5 (Optional): Delete the query
my_query.delete_query()

CHANGELOG

[Unreleased]

  • Add --help option to query.py
  • Add push.py to qapi-sdk package to push data to Athena

[0.1.4] - 2022-05-29

  • Added the CHANGELOG section.

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

qapi-sdk-0.1.4.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

qapi_sdk-0.1.4-py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page