SQLAlchemy PGSpider Dialect

0.1.0 · active · verified Fri Apr 17

SQLAlchemy-PGSpider is a Python library that provides a dialect for SQLAlchemy, enabling it to connect to PGSpider databases. As of version 0.1.0, it offers fundamental connectivity and query execution. It is a new project in active development, likely following a release cadence tied to upstream PGSpider and SQLAlchemy updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to establish a connection to a PGSpider database using `create_engine` with the 'pgspider://' URI and execute a simple query. Ensure you have the `PGSPIDER_CONN_STR` environment variable set or update the placeholder directly.

from sqlalchemy import create_engine, text
import os

# Replace with your PGSpider connection details
# For example: "pgspider://user:password@host:port/database"
PGSPIDER_CONN_STR = os.environ.get('PGSPIDER_CONN_STR', 'pgspider://postgres:password@localhost:5432/pgspider_db')

try:
    engine = create_engine(PGSPIDER_CONN_STR)

    with engine.connect() as connection:
        result = connection.execute(text("SELECT 1"))
        print(f"PGSpider connection successful. Result: {result.scalar()}")

except Exception as e:
    print(f"Error connecting to PGSpider: {e}")

view raw JSON →