Skip to main content

Introduction to Legion Query Runners

Legion Query Runners is a Python package that provides a unified interface for executing queries, retrieving schemas, and handling result sets across different database systems. It allows you to interact with various databases using a consistent API.

Key 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
  • Authentication Support: Handle various authentication methods including IAM for AWS services

Supported Database Systems

Legion Query Runners supports a variety of database systems including:

  • SQLite
  • MySQL and RDS MySQL
  • Microsoft SQL Server
  • PostgreSQL
  • Oracle
  • BigQuery
  • And more...

Getting Started

Get started with Legion Query Runners by installing the package and configuring your first database connection:

pip install legion-query-runner

Basic Usage

from legion_query_runner.query_runner import QueryRunner

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

# 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'])}")

Explore the documentation to learn more about each query runner and its specific configuration options.