Skip to main content

llama-index readers athena integration

Project description

Athena reader.

pip install llama-index-readers-athena

pip install llama-index-llms-openai

Athena reader allow execute SQL with AWS Athena. We using SQLAlchemy and PyAthena under the hood.

Permissions

WE HIGHLY RECOMMEND USING THIS LOADER WITH AWS EC2 IAM ROLE.

Usage

Here's an example usage of the AthenaReader.

import os
import dotenv
from llama_index.core import SQLDatabase,ServiceContext
from llama_index.core.query_engine import NLSQLTableQueryEngine
from llama_index.llms.openai import OpenAI
from llama_index.readers.athena import AthenaReader

dotenv.load_dotenv()

AWS_REGION = os.environ['AWS_REGION']
S3_STAGING_DIR = os.environ['S3_STAGING_DIR']
DATABASE = os.environ['DATABASE']
WORKGROUP = os.environ['WORKGROUP']
TABLE = os.environ['TABLE']

llm = OpenAI(model="gpt-4",temperature=0, max_tokens=1024)

engine = AthenaReader.create_athena_engine(
    aws_region=AWS_REGION,
    s3_staging_dir=S3_STAGING_DIR,
    database=DATABASE,
    workgroup=WORKGROUP
)

service_context = ServiceContext.from_defaults(
  llm=llm
)

sql_database = SQLDatabase(engine, include_tables=[TABLE])

query_engine = NLSQLTableQueryEngine(
    sql_database=sql_database,
    tables=[TABLE],
    service_context=service_context
)
query_str = (
    "Which blocknumber has the most transactions?"
)
response = query_engine.query(query_str)

Screeshot

image

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

llama_index_readers_athena-0.5.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

llama_index_readers_athena-0.5.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_readers_athena-0.5.0.tar.gz.

File metadata

  • Download URL: llama_index_readers_athena-0.5.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_readers_athena-0.5.0.tar.gz
Algorithm Hash digest
SHA256 9b87c12b31aee97a12cec417bfcc912116ec6e28a937a99cef156b421046efe1
MD5 1cf473a7f71bfec8bd4f6d44523982c9
BLAKE2b-256 394b702fd4ddd5bae02958ab44421cd4397482f5fc4c289abcfb82458aea3f78

See more details on using hashes here.

File details

Details for the file llama_index_readers_athena-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_readers_athena-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_readers_athena-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 de5371a7c4280d5aa668943fef979315f097d7c7e96b857386a293c42d0f4630
MD5 ac2010808c217ac87a17bb48dae62692
BLAKE2b-256 79f6dd4dc4bfcb11cd6fa8a44bf390e03846c397c1e9318076d33a950e03bf15

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