Skip to content

aws_s3

aws_s3 postgres extension to import/export data from/to s3

aws_s3 · aws_s3 postgres extension to import/export data from/to s3

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
8800aws_s3aws_s30.0.1FDWApache-2.0SQL
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
----d-rNoNoNoYesyesno

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY0.0.119 18 17 16 15aws_s3-
RPMPIGSTY0.0.119 18 17 16 15aws_s3_$v-
DEBPIGSTY0.0.119 18 17 16 15postgresql-$v-aws-s3-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
el8.aarch64N/APIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
el9.x86_64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
el9.aarch64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
el10.x86_64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
el10.aarch64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
d12.x86_64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
d12.aarch64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
d13.x86_64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
d13.aarch64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
u22.x86_64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
u22.aarch64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
u24.x86_64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
u24.aarch64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
u26.x86_64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
u26.aarch64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
PackageVersionOSORGSIZEFile URL
aws_s3_190.0.1el9.x86_64pigsty9.2 KiBaws_s3_19-0.0.1-1PGSTY.el9.noarch.rpm
aws_s3_190.0.1el9.aarch64pigsty9.2 KiBaws_s3_19-0.0.1-1PGSTY.el9.noarch.rpm
aws_s3_190.0.1el10.x86_64pigsty9.4 KiBaws_s3_19-0.0.1-1PGSTY.el10.noarch.rpm
aws_s3_190.0.1el10.aarch64pigsty9.4 KiBaws_s3_19-0.0.1-1PGSTY.el10.noarch.rpm
postgresql-19-aws-s30.0.1d12.x86_64pigsty10.4 KiBpostgresql-19-aws-s3_0.0.1-1PGSTY~bookworm_all.deb
postgresql-19-aws-s30.0.1d12.aarch64pigsty10.4 KiBpostgresql-19-aws-s3_0.0.1-1PGSTY~bookworm_all.deb
postgresql-19-aws-s30.0.1d13.x86_64pigsty10.4 KiBpostgresql-19-aws-s3_0.0.1-1PGSTY~trixie_all.deb
postgresql-19-aws-s30.0.1d13.aarch64pigsty10.4 KiBpostgresql-19-aws-s3_0.0.1-1PGSTY~trixie_all.deb
postgresql-19-aws-s30.0.1u22.x86_64pigsty10.3 KiBpostgresql-19-aws-s3_0.0.1-1PGSTY~jammy_all.deb
postgresql-19-aws-s30.0.1u22.aarch64pigsty10.3 KiBpostgresql-19-aws-s3_0.0.1-1PGSTY~jammy_all.deb
postgresql-19-aws-s30.0.1u24.x86_64pigsty10.3 KiBpostgresql-19-aws-s3_0.0.1-1PGSTY~noble_all.deb
postgresql-19-aws-s30.0.1u24.aarch64pigsty10.3 KiBpostgresql-19-aws-s3_0.0.1-1PGSTY~noble_all.deb
postgresql-19-aws-s30.0.1u26.x86_64pigsty10.4 KiBpostgresql-19-aws-s3_0.0.1-1PGSTY~resolute_all.deb
postgresql-19-aws-s30.0.1u26.aarch64pigsty10.4 KiBpostgresql-19-aws-s3_0.0.1-1PGSTY~resolute_all.deb

Source

pig build pkg aws_s3;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install aws_s3;		# install by package name

pig install aws_s3 -v 19;   # install for PG 19
pig install aws_s3 -v 18;   # install for PG 18
pig install aws_s3 -v 17;   # install for PG 17
pig install aws_s3 -v 16;   # install for PG 16
pig install aws_s3 -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION aws_s3;

Usage

aws_s3: PostgreSQL extension to import/export data from/to S3

Setup Credentials

Configure AWS credentials via PostgreSQL session variables:

SET aws_s3.access_key_id TO 'your_access_key';
SET aws_s3.secret_key TO 'your_secret_key';
SET aws_s3.session_token TO 'optional_session_token';  -- if using temporary credentials

For local development with LocalStack:

SET aws_s3.endpoint_url TO 'http://localhost:4566';

Import Data from S3

CREATE EXTENSION aws_s3;

CREATE TABLE animals (
  name text,
  age int
);

SELECT aws_s3.table_import_from_s3(
  'animals',
  '',
  '(FORMAT CSV, DELIMITER '','', HEADER true)',
  'my-bucket',
  'animals.csv',
  'us-east-1'
);

SELECT * FROM animals;

Parameters: table name, column list (empty string for all), COPY options, S3 bucket, S3 key, AWS region.

Export Data to S3

SELECT * FROM aws_s3.query_export_to_s3(
  'SELECT * FROM animals',
  'my-bucket',
  'export/animals.csv',
  'us-east-1',
  options := 'FORMAT CSV, HEADER true'
);

Parameters: SQL query, S3 bucket, S3 key, AWS region, COPY options.

Features

  • Files with Content-Encoding=gzip metadata are automatically decompressed during import
  • Credentials can be passed directly as function arguments or via session variables
  • Uses the same COPY format options as PostgreSQL (CSV, TEXT, BINARY, with all related settings like DELIMITER, HEADER, NULL, etc.)

Table reader