Skip to main content

altertable-flightsql

Python client library for Altertable.

License Python

Installation

pip install altertable-flightsql

Quick Start

from altertable_flightsql import Client

# Connect to Altertable
with Client(username="your_username", password="your_password") as client:
    # Execute a query
    reader = client.query("SELECT * FROM users WHERE age > 18")

    # Process results
    for batch in reader:
        df = batch.data.to_pandas()
        print(df)

Connect to specific catalog/schema

# Connect to custom host/port
client = Client(
    username="admin",
    password="secret",
    catalog="my_catalog",
    schema="my_schema"
)

Compute size

from altertable_flightsql import Client, ComputeSize

client = Client(username="admin", password="secret", compute_size=ComputeSize.L)

The size is fixed when the session runs its first query, so set it in the constructor or call client.set_compute_size(...) before querying.

Queries and Updates

# Execute SELECT query
reader = client.query("SELECT * FROM users")
for batch in reader:
    print(batch.data.to_pandas())

# Execute INSERT/UPDATE/DELETE
rows_affected = client.execute("INSERT INTO users (name) VALUES ('Alice')")
print(f"Affected {rows_affected} rows")

Prepared Statements

# Prepare once, execute multiple times
with client.prepare("SELECT * FROM users WHERE id = $id") as stmt:
    result = stmt.query(parameters={"id": 1}))
    for batch in result:
        print(batch.data.to_pandas())

Transactions

with client.begin_transaction():
    client.execute("INSERT INTO users ...")
    client.execute("UPDATE accounts ...")

Metadata Queries

# Get catalogs, schemas, tables
catalogs = client.get_catalogs()
schemas = client.get_schemas(catalog="my_db")
tables = client.get_tables(catalog="my_db", schema_pattern="public")

Development

Setup

# Clone repository
git clone https://github.com/altertable-ai/altertable-flightsql-python.git
cd altertable-flightsql-python

# Install with dev dependencies
pip install -e ".[dev]"

Running Tests

pytest                           # Run tests

Code Quality

make lint                        # Run all linters (isort, black, ruff, mypy)

Compiling Protocol Definitions

If you modify the .proto files, you need to recompile them:

make gen                         # Compile protobuf definitions

Important: The CI will fail if generated files are out of sync with the proto definitions. Always run make gen and commit the generated files after modifying .proto files.

Examples

See the examples/ directory for complete examples:

# High-level client examples
python examples/client_usage.py

Testing

This package includes comprehensive integration tests that validate functionality against a real Altertable service.

Running Tests

Using testcontainers (local development):

# Install development dependencies
pip install -e ".[dev]"

# Run all tests
# Having the ghcr.io/altertable-ai/altertable-mock docker image locally will speed things up.
pytest tests/

By default the mock service container is launched using the host's native architecture (linux/arm64 on Apple Silicon, linux/amd64 on Intel/Linux), so no emulation is required. To override the platform — for example to force linux/amd64 for parity with CI — set ALTERTABLE_MOCK_PLATFORM:

ALTERTABLE_MOCK_PLATFORM=linux/amd64 pytest tests/

Set ALTERTABLE_MOCK_PLATFORM= (empty) to let Docker pick the default from the image manifest.

Using an existing service (CI/production):

# Set environment variables
export ALTERTABLE_HOST=localhost
export ALTERTABLE_PORT=15002
export ALTERTABLE_USERNAME=altertable-test
export ALTERTABLE_PASSWORD=lk_test

# Run tests
pytest tests/

The test suite automatically detects whether to use testcontainers or an existing service based on environment variables. If ALTERTABLE_HOST and ALTERTABLE_PORT are set, tests will connect to that service. Otherwise, they'll start a Docker container with altertable.ai/altertable-mock.

Contributing

Contributions are welcome!

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes with tests
  4. If you modified .proto files, run make gen
  5. Run code quality checks: make lint and pytest
  6. Commit your changes (git commit -m 'Add amazing feature')
  7. Push to the branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

Development Guidelines

  • Follow PEP 8 style (enforced by Black, line length: 100)
  • Add tests for new features
  • Include docstrings (Google style)
  • Update documentation as needed
  • Run make gen and commit generated files when modifying .proto files
  • Run make lint before committing to ensure code quality

Architecture

altertable-flightsql/
├── src/altertable_flightsql/
│   ├── __init__.py              # Package exports
│   ├── client.py                # Main Client class
│   └── generated/               # Internal protocol definitions
├── tests/                       # Test suite
└── examples/                    # Usage examples

License

MIT License - See LICENSE file for details.

Built on Apache Arrow Flight SQL protocol.

Resources

Acknowledgments

Built on Apache Arrow Flight SQL protocol.

Metadata

Release files for altertable-flightsql 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for altertable-flightsql 0.4.1
File Size Uploaded
altertable_flightsql-0.4.1.tar.gz 58.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for altertable-flightsql 0.4.1
File Interpreter ABI Platform
altertable_flightsql-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 88.2 kB

Release files / altertable_flightsql-0.4.1.tar.gz

Download URL altertable_flightsql-0.4.1.tar.gz
Size 58.3 kB
Tags Source
SHA-256 checksum
How to use checksums
077652f60417318a9a20fa9fd783f589c58dd5c0983fbb29f47557293d7e7bc9
BLAKE2b-256 checksum
How to use checksums
b3d96af7bdc202ab5b65e2933e75cb264fa834a380a09e10e42498ac601f3ddd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / altertable_flightsql-0.4.1-py3-none-any.whl

Download URL altertable_flightsql-0.4.1-py3-none-any.whl
Size 29.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ebc4fd35706569ee1ebd17f638e6dd6c9045e97c0af63c06ac7c2fc065223143
BLAKE2b-256 checksum
How to use checksums
1ebc65abba8a2151587c3e3ad8e651439cbcc12ef3591809df3976ea8727e207
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page