Skip to main content

SQLAlchemy dialect for PowerDrill

Project description

PowerDrill SQLAlchemy Dialect

SQLAlchemy dialect for PowerDrill AI, enabling natural language queries through SQLAlchemy's ORM interface. This dialect allows you to interact with PowerDrill's AI-powered data analysis capabilities using familiar SQLAlchemy patterns.

Installation

pip install sqlalchemy-powerdrill

Quick Start

from sqlalchemy import create_engine, text, inspect

# Create engine with credentials
engine = create_engine(
    'powerdrill://ai.data.cloud'
    '?api_key=your-api-key'
    '&user_id=your-user-id'
    '&dataset_id=your-dataset-id'
    '&api_version=v1'  # Optional, defaults to v1
)

# Execute natural language queries
with engine.connect() as connection:
    # Natural language query
    result = connection.execute(text("四个直辖市的全称、区号"))
    for row in result:
        print(row)
    
    # List available datasets
    inspector = inspect(engine)
    datasets = inspector.get_schema_names()
    print("Available datasets:", datasets)

Features

  • Natural Language Queries: Write queries in natural language
  • Dataset Management: List and explore available datasets
  • SQLAlchemy Integration: Seamless integration with SQLAlchemy ORM patterns
  • Streaming Support: Handle large result sets efficiently
  • JSON Response Format: Structured JSON output for easy data processing

Connection URL Format

The PowerDrill SQLAlchemy dialect uses the following connection URL format:

powerdrill://[host]?api_key=[api_key]&user_id=[user_id]&dataset_id=[dataset_id]&api_version=[api_version]

Connection Parameters

  • host: The PowerDrill API host
  • api_key: Your PowerDrill API key
  • user_id: Your PowerDrill user ID
  • dataset_id: ID of the dataset to query
  • api_version: API version to use (optional, defaults to 'v1')

Requirements

  • Python >= 3.7
  • SQLAlchemy >= 1.4.0, < 2.0.0
  • requests >= 2.31.0

License

MIT License

Support

For support or bug reports, please contact dev@powerdrill.ai.

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

sqlalchemy_powerdrill-0.3.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

sqlalchemy_powerdrill-0.3.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file sqlalchemy_powerdrill-0.3.0.tar.gz.

File metadata

  • Download URL: sqlalchemy_powerdrill-0.3.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.9

File hashes

Hashes for sqlalchemy_powerdrill-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0a2401d61fb2fde2e018fffe2dcd3adc5858aecc0d51b718880a165377ba3035
MD5 b21d65aa383bfa359c504b58d22b75c0
BLAKE2b-256 fa0435ff795d8475109d7edfcd1afc65c98d3a4b260884541cb0d63c591ef194

See more details on using hashes here.

File details

Details for the file sqlalchemy_powerdrill-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sqlalchemy_powerdrill-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 152152d3f1f7704eb54e18b0d2f479beb1a6c07f7b9b5a0d3eaabe326349b709
MD5 0b0fd2f8859ee7a564001634458035bc
BLAKE2b-256 1726afdd926f74ebf2574136602f07f0b526a2bd81fcf642ec1fc0d3287d072f

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