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
- Redshift (with IAM User/Role)
- CockroachDB
- MySQL
- MySQL (Amazon RDS)
- Microsoft SQL Server
- Microsoft SQL Server (ODBC)
- Big Query
- Oracle DB
- SQLite
- Amazon Athena
- Apache Hive
- Apache Hive (HTTP)
- Databricks
- Snowflake
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:
-
Install dependencies:
poetry install --with dev
-
Run tests:
poetry run pytest
Publish
poetry publish --build
License
Proprietary - All rights reserved by Legion.
Metadata
Release files for legion-query-runner 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| legion_query_runner-0.2.0.tar.gz | 31.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| legion_query_runner-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 75.2 kB
Release files / legion_query_runner-0.2.0.tar.gz
| Download URL | legion_query_runner-0.2.0.tar.gz |
|---|---|
| Size | 31.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8b82122c81cd3e07986eaf69a2e89b17a81b8e4dfe22bf04d66eac02199d1f58
|
|
BLAKE2b-256 checksum How to use checksums |
eda7579a262a9b03474de1df3d3c4622ae04044e31374549bf8df329f303473a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.2 CPython/3.11.7 Darwin/24.3.0
|
Release files / legion_query_runner-0.2.0-py3-none-any.whl
| Download URL | legion_query_runner-0.2.0-py3-none-any.whl |
|---|---|
| Size | 43.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6c4767fd11278e3072696b50b9a547ca77bf2c684e3a602f17175b9ec1ce04b9
|
|
BLAKE2b-256 checksum How to use checksums |
f3e2e6154cd0a59bbd1bd918531d3ee5ede0482eb624de8c34c744a52f9954cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.2 CPython/3.11.7 Darwin/24.3.0
|