Extract data from Amazon Redshift into Semantica with password/native or IAM-role authentication, using the PostgreSQL-compatible wire protocol.
Installation
redshift-connector is an optional dependency. A plain pip install semantica never pulls it in, and import semantica.ingest never loads it eagerly — the SDK is imported only when you first use RedshiftConnector or RedshiftIngestor.
This connector uses the Redshift database wire protocol for read ingestion. COPY, UNLOAD, S3 integration, Spectrum external tables, and the Redshift Data API are outside the current scope of this integration.
Basic Usage
Authentication
- Password / Native
- IAM Role (Recommended for AWS)
The standard Redshift database username and password:Required environment variables:
Environment Variables
All constructor parameters haveREDSHIFT_* environment-variable fallbacks.
Explicit constructor values always take precedence.
Querying
Ingest a table
Schema, filters, and pagination
Custom SQL
Parameterized queries
Use%s placeholders (DB-API 2.0 format paramstyle, which is the default for redshift-connector):
Batch fetching for large result sets
Usebatch_size to control the driver fetch size — rows are fetched from
the server in chunks of that size rather than all at once, and each chunk is
converted immediately before the next is requested:
batch_size controls how many rows the driver reads from Redshift per
round-trip. The returned RedshiftData.data list still contains all matching
rows; use LIMIT/OFFSET in the query itself if you need to cap the total
result size.
Schema Discovery
List base tables in a schema
Inspect column metadata
primary_keys is a list of column-name strings (empty list when no primary key is defined).
Export as Semantica Documents
Convert ingested rows to the document format thatGraphBuilder consumes:
str(row.get(id_field, row_index)) — the integer row index is used as a deterministic fallback when the id_field column is absent.
Text when text_fields is provided: each non-None field value is converted to a string and joined with a single space.
Text when text_fields=None: only columns whose values are already str type are joined. Integer, float, boolean, and None values are excluded, matching the Snowflake and Databricks connector behavior.
Pass the documents directly to GraphBuilder:
Context Manager
Prefer the context manager for jobs that run multiple queries — it opens one connection on entry and closes it on exit, so every call inside thewith block reuses the same authenticated session:
with) open and close a transient connection per call.
Connection Test
See Also
- Ingest Module — Full
RedshiftIngestorreference and all other ingestors. - Snowflake Integration — SQL data warehouse connector with similar table/query ingestion.
- Databricks Integration — Delta Lake / Unity Catalog connector.
- Pipeline — Use Redshift ingestion as a pipeline step.
- Installation — All optional dependency extras.
- Knowledge Graph — Build a knowledge graph from ingested Redshift data.
