Migrating Data from PostgreSQL

This page covers PostgreSQL-specific setup for Data migration. For workflow and Worker field definitions, see Data migration configuration reference.

Prerequisites

  • Npgsql driver (pure Python) on Workers. You don’t install a PostgreSQL ODBC driver for cloud migration.
  • TLS configuration: Set ssl_mode in Worker TOML (Disable, Prefer, Require, VerifyCA, VerifyFull). Default Require for managed hosts; use Disable for local Docker or lab instances without TLS.

Connectivity and extraction

PostgreSQL uses regular extraction (partitioned SELECT through the Worker to Parquet, then the internal migration stage).

Managed host (TLS required)

[connections.source.postgresql]
auth_method = "standard"
username = "scai"
password = "your_password"
database = "analytics"
host = "db.example.com"
port = "5432"
ssl_mode = "Require"
use_copy = true

Local Docker or lab (no TLS)

[connections.source.postgresql]
auth_method = "standard"
username = "scai"
password = "scai"
database = "scai_pg"
host = "localhost"
port = "5432"
ssl_mode = "Disable"
use_copy = true

Workflow example:

tables:
  - source:
      databaseName: analytics
      schemaName: public
      tableName: customers
    target:
      databaseName: TARGET_DB
      schemaName: PUBLIC
      tableName: customers
    columnNamesToPartitionBy:
      - customer_id

Data type mappings

PostgreSQL typeSnowflake target typeSupported for migrationNotes
smallint, integer, bigint, serial typesNUMBERYes
numeric(p,s), decimalNUMBERYesDefault NUMBER(20,10) when unspecified
real, double precisionFLOATYes
booleanBOOLEANYes
dateDATEYes
time without/with time zoneTIMEYes
timestamp without/with time zoneTIMESTAMP_NTZ / TIMESTAMP_TZYes
character, character varying, textVARCHARYes
byteaBINARYYes
uuidVARCHAR(36)Yes
json, jsonb, xmlVARIANTYes
moneyVARCHARYesStored as a text representation
bit, bit varyingVARCHARYesStored as a text representation
intervalVARCHARYesStored as a text representation
arrayARRAYYes
inet, cidr, macaddr typesVARCHARYesStored as a text representation
point, line, lseg, box, path, polygon, circleVARCHARYesNative PostgreSQL geometric types stored as text
PostGIS geometryGEOMETRYYes
PostGIS geographyGEOGRAPHYYes
pg_lsn, pg_snapshot, txid_snapshot(unmapped)No

Platform-specific suggestions

  • use_copy = true: PostgreSQL native COPY protocol is enabled by default for cloud migration and significantly improves extraction speed on large tables.
  • ssl_mode: Set this to match your environment. Most managed cloud PostgreSQL hosts require Require or stricter.
  • PostGIS columns: Deploy converted DDL with GEOMETRY or GEOGRAPHY target columns before migrating so Snowflake receives the spatial type shown in the table above. Native point, line, and polygon types always map to VARCHAR.
  • Anti-locking: No automatic hint is added on PostgreSQL. Set queryModifiers only when you need custom source SQL hints. See Anti-locking and query modifiers.