Skip to main content

Query runners

Project description

Legion Query Runners

This package provides query runners for Legion, supporting various database systems and data sources. The package provides a unified interface for executing queries, retrieving schemas, and handling result sets across different database systems.

Supported Data Sources

  • PostgreSQL
  • Redshift
  • CockroachDB
  • MySQL
  • RDS MySQL
  • Microsoft SQL Server
  • Big Query
  • Oracle DB
  • SQLite

Installation

pip install legion-query-runner

Basic Usage

from legion_query_runner.query_runner import QueryRunner

# Initialize with database configuration
sqlite_config = {
    "database": "/path/to/your/database.sqlite"
}

# Example with SSH tunnel configuration
pg_config = {
    "host": "internal-db.example.com",
    "port": 5432,
    "user": "username",
    "password": "password",
    "dbname": "database_name",
    "ssh_tunnel_enabled": True,
    "ssh_host": "bastion.example.com",
    "ssh_port": 22,
    "ssh_username": "ssh_user"
}

# Create a QueryRunner instance
runner = QueryRunner('sqlite', sqlite_config)

# Test connection
runner.test_connection()

# Execute a query
results = runner.run_query("SELECT * FROM users LIMIT 10")
print(f"Columns: {results['columns']}")
print(f"Row count: {len(results['rows'])}")

# Get schema
schema = runner.get_schema()
for table in schema:
    print(f"Table: {table['name']}")
    for column in table['columns']:
        print(f"  - {column['name']} ({column['type']})")

# Get columns for a specific table
columns = runner.get_table_columns("users")
print(f"Columns in users table: {columns}")

# Get column types for a specific table
column_types = runner.get_table_types("users")
print(f"Column types in users table: {column_types}")

Core Features

  • Unified Database Interface: Interact with different databases using a consistent API
  • Schema Retrieval: Get table and column information from your database
  • Type Inference: Automatic detection of column data types
  • Query Execution: Run SQL queries and process results in a standardized format
  • Connection Management: Establish, test, and maintain database connections
  • SSH Tunneling: Connect to databases through SSH tunnels with bastion host support
  • Authentication Support: Handle various authentication methods including IAM for AWS services

Development

To set up the development environment:

  1. Install dependencies:

    poetry install --with dev
    
  2. Run tests:

    poetry run pytest
    

Publish

poetry publish --build

License

Proprietary - All rights reserved by Legion.

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

legion_query_runner-0.1.4.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

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

legion_query_runner-0.1.4-py3-none-any.whl (34.1 kB view details)

Uploaded Python 3

File details

Details for the file legion_query_runner-0.1.4.tar.gz.

File metadata

  • Download URL: legion_query_runner-0.1.4.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.9 Darwin/24.3.0

File hashes

Hashes for legion_query_runner-0.1.4.tar.gz
Algorithm Hash digest
SHA256 cb853d0395922bf3ed97044ebed5964f22ab12a3c87a45a279f97438bc900925
MD5 8a3be43e22d03fd469ea3b310b960ad4
BLAKE2b-256 d1a40e6227c5423843e555742a97081e37d50eb0d091e4648063c5f4cdbc2162

See more details on using hashes here.

File details

Details for the file legion_query_runner-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for legion_query_runner-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 caea495a987bd2e7a38d4777e8592180dd228243e1db5f178b67d86b26453b25
MD5 041fc9592592befb28d36a00aac67de7
BLAKE2b-256 0bbab87ed5d4e99dc875f428fef89a98c70f084db2eacce5d3475a54b8e2e3a2

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