{
  "name": "sql-to-s3",
  "title": "Run a SQL query and write results to S3 as CSV",
  "description": "Run a SQL query against a Postgres database and write the result set to Amazon S3 as a CSV object. Connection string and AWS credentials are read from Kubernetes Secrets.",
  "category": "Data",
  "tags": [
    "data",
    "python"
  ],
  "latestVersion": "1.1.2",
  "versions": [
    "1.1.2",
    "1.1.1",
    "1.1.0",
    "1.0.1",
    "1.0.0"
  ],
  "parameters": [
    "bucket",
    "key",
    "query",
    "aws-access-key-id-key",
    "aws-secret-access-key-key",
    "aws-secret-name",
    "db-secret-key",
    "db-secret-name",
    "region"
  ],
  "images": [
    "python@sha256:94d3426f1def7db4a106a232ac121bfd975393e5dfd40a619b955fae45fe7913"
  ],
  "url": "https://catalog.dagweave.com/api/v1/items/sql-to-s3.json",
  "templateUrl": "https://catalog.dagweave.com/api/v1/items/sql-to-s3/latest/template.yaml",
  "page": "https://catalog.dagweave.com/items/sql-to-s3/",
  "entrypoint": "export",
  "parameterDetails": [
    {
      "name": "bucket",
      "title": "Bucket",
      "description": "Target S3 bucket for the CSV result (no s3:// prefix).",
      "type": "string",
      "required": true,
      "example": "my-data-bucket"
    },
    {
      "name": "key",
      "title": "Object key",
      "description": "Destination object key for the CSV result.",
      "type": "string",
      "required": true,
      "example": "exports/users.csv"
    },
    {
      "name": "query",
      "title": "SQL query",
      "description": "SQL query to run against the Postgres database.",
      "type": "string",
      "required": true,
      "example": "SELECT id, email FROM users WHERE active"
    },
    {
      "name": "aws-access-key-id-key",
      "title": "Access key id secret key",
      "description": "Key within the Secret that holds the AWS access key id.",
      "type": "string",
      "required": false,
      "default": "access-key-id"
    },
    {
      "name": "aws-secret-access-key-key",
      "title": "Secret access key secret key",
      "description": "Key within the Secret that holds the AWS secret access key.",
      "type": "string",
      "required": false,
      "default": "secret-access-key"
    },
    {
      "name": "aws-secret-name",
      "title": "AWS secret name",
      "description": "Name of the Kubernetes Secret in the run namespace holding the AWS credentials.",
      "type": "string",
      "required": false,
      "default": "aws-credentials"
    },
    {
      "name": "db-secret-key",
      "title": "DB secret key",
      "description": "Key within the Secret that holds the Postgres connection string.",
      "type": "string",
      "required": false,
      "default": "connection-string"
    },
    {
      "name": "db-secret-name",
      "title": "DB secret name",
      "description": "Name of the Kubernetes Secret holding the Postgres connection string (DSN / libpq URL).",
      "type": "string",
      "required": false,
      "default": "postgres-credentials"
    },
    {
      "name": "region",
      "title": "AWS region",
      "description": "AWS region of the bucket.",
      "type": "string",
      "required": false,
      "default": "us-east-1"
    }
  ],
  "imageDetails": [
    {
      "ref": "python@sha256:94d3426f1def7db4a106a232ac121bfd975393e5dfd40a619b955fae45fe7913",
      "repository": "python",
      "digest": "sha256:94d3426f1def7db4a106a232ac121bfd975393e5dfd40a619b955fae45fe7913"
    }
  ],
  "versionDetails": [
    {
      "version": "1.1.2",
      "date": "2026-10-16",
      "notes": "Repin python on 3.15-slim and move psycopg2-binary 2.9.12 to 2.9.13, the first release with CPython 3.15 wheels. 2.9.12 had none, so pip fell back to building it from source and failed for want of pg_config.",
      "latest": true,
      "installable": true,
      "url": "https://catalog.dagweave.com/api/v1/items/sql-to-s3/1.1.2.json",
      "templateUrl": "https://catalog.dagweave.com/api/v1/items/sql-to-s3/1.1.2/template.yaml"
    },
    {
      "version": "1.1.1",
      "date": "2026-08-18",
      "notes": "Repin python:3.13-slim on the current digest, in ./Dockerfile as well as here. Same tag, CPython 3.13.14 to 3.13.15, and Entrypoint, Cmd, User and WorkingDir are identical on both. The repin clears nothing: util-linux CVE-2026-53615 is on the new bytes too. What it buys is a record that holds, because an OS baseline covers a pin only while that pin is its tag's head, and this one had fallen behind. pip also moves 26.1.2 to 26.2.1, which ships an SBOM of its vendored tree, so trivy now reports the msgpack and setuptools the old pin already vendored without declaring; both are recorded in hack/image-cve-exceptions.txt. This is the one item that runs pip, and it runs it with --no-cache-dir, which is the cache msgpack serialises. psycopg2-binary 2.9.12 and boto3 1.43.68 both resolve to wheels on this interpreter, so no sdist build runs either.",
      "latest": false,
      "installable": false,
      "url": "https://catalog.dagweave.com/api/v1/items/sql-to-s3/1.1.1.json"
    },
    {
      "version": "1.1.0",
      "date": "2026-08-12",
      "notes": "Cut ahead of the first image push: build-item-images reads the tag it pushes out of this file, so the version has to move before the dispatch or the first tag names the release that installs psycopg2-binary and boto3 from PyPI on every run. The template still does that install. It moves onto the image, and this entry gets the digest, once the package exists and is public.",
      "latest": false,
      "installable": false,
      "url": "https://catalog.dagweave.com/api/v1/items/sql-to-s3/1.1.0.json"
    },
    {
      "version": "1.0.1",
      "date": "2026-08-11",
      "notes": "Pin psycopg2-binary to 2.9.12 and boto3 to 1.43.68 in the run-time install. They floated, so the digest froze the image and not the code that ran in it.",
      "latest": false,
      "installable": false,
      "url": "https://catalog.dagweave.com/api/v1/items/sql-to-s3/1.0.1.json"
    },
    {
      "version": "1.0.0",
      "date": "2026-07-16",
      "notes": "Initial release.",
      "latest": false,
      "installable": false,
      "url": "https://catalog.dagweave.com/api/v1/items/sql-to-s3/1.0.0.json"
    }
  ],
  "source": "https://github.com/dagweave/catalog/tree/67458f74dbbf913b03177f3cefc69424be85eb1d/catalog/sql-to-s3",
  "catalogSha": "67458f74dbbf913b03177f3cefc69424be85eb1d"
}
