Arrow Flight SQL
Connect an Arrow Flight SQL client to Altertable over TLS, run a query, and confirm that the client can stream Arrow record batches.
Prerequisites
- Your lakehouse username and password.
- An Arrow Flight SQL-compatible client.
For the Python examples, install the Flight SQL client:
pip install altertable-flightsql
Connect
Hostname | Port |
|---|---|
flight.altertable.ai | 443 (TLS/SSL) |
Enable TLS and authenticate with your lakehouse username and password. For Metabase driver configuration, see Connect Metabase.
Run your first query
Run a query that does not depend on an existing table:
The result should contain one ok column with the value 1.
Use the Python client
Altertable provides an official Python client library (altertable-flightsql) that handles authentication, connection management, queries, prepared statements, transactions, and metadata operations.
Prepared statements
Prepare a statement once and execute it multiple times with different parameters:
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
Execute multiple statements atomically:
with client.begin_transaction():client.execute("INSERT INTO users ...")client.execute("UPDATE accounts ...")
Metadata queries
Discover catalogs, schemas, and tables:
catalogs = client.get_catalogs()schemas = client.get_schemas(catalog="my_db")tables = client.get_tables(catalog="my_db", schema_pattern="main")
For more details, examples, and advanced usage, see the GitHub repository.
Connect another client
Any Arrow Flight SQL-compatible client can connect to flight.altertable.ai:443 with TLS.
Python ADBC
Troubleshooting
- Authentication fails: copy the lakehouse username and password from the same environment again.
- The TLS connection fails: connect to
flight.altertable.ai:443and keep TLS enabled. - A table cannot be found: use
get_catalogs(),get_schemas(), andget_tables()to confirm its fully qualified name. - A generic client cannot connect: confirm that it supports Arrow Flight SQL rather than only the Arrow in-memory format.
Next steps
- Query with the HTTP API when HTTPS and JSONL fit the integration better.
- Connect Metabase through Arrow Flight SQL or the Postgres adapter.
- See the Python client repository for advanced examples.