Skip to main content

Convert Convex snapshot exports to PostgreSQL schema and data SQL files

Project description

convex2pg

Convert a Convex snapshot export to PostgreSQL schema.sql + data.sql files.

Zero dependencies — standard library only.

Install

pip install -e ~/dev/convex2pg

# or with pipx (recommended for CLI tools)
pipx install ~/dev/convex2pg

Usage

# Write schema.sql + data.sql into the export directory
convex2pg ./my-convex-export/

# Write to a different output directory
convex2pg ./my-convex-export/ --output ./sql/

# Schema only (no inserts)
convex2pg ./my-convex-export/ --schema-only

# Data only (no CREATE TABLE)
convex2pg ./my-convex-export/ --data-only

# Print to stdout (pipe into psql)
convex2pg ./my-convex-export/ --stdout | psql -U user -d mydb

# Show per-table details
convex2pg ./my-convex-export/ --verbose

Convex export format

A Convex snapshot export is a directory containing:

export/
├── _tables/documents.jsonl        # table metadata (skipped)
├── <table>/
│   ├── documents.jsonl            # one JSON object per line
│   └── generated_schema.jsonl    # Convex type info
└── _components/
    └── <component>/
        └── <table>/
            ├── documents.jsonl
            └── generated_schema.jsonl

Type mapping

Convex type PostgreSQL type
normalfloat64 DOUBLE PRECISION
normalint64 BIGINT
field_name TEXT
boolean BOOLEAN
array/object JSONB
Convex ID (_id, *Id fields) VARCHAR(50)
Timestamp fields (*At, *Time, expires*) BIGINT (ms since epoch)

Timestamps are stored as milliseconds since epoch (BIGINT). Convert to TIMESTAMP in PostgreSQL with:

SELECT to_timestamp(created_at / 1000.0) FROM "user";

Load into PostgreSQL

psql -U youruser -d yourdb -f schema.sql
psql -U youruser -d yourdb -f data.sql

This was written entirely by Claude

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

convex2pg-0.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

convex2pg-0.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file convex2pg-0.1.0.tar.gz.

File metadata

  • Download URL: convex2pg-0.1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for convex2pg-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9c9fa04f84d52daeaf7172c6ec1ceb7db73bc29cc16736eff01fcb7fb7b34cf2
MD5 75ba2f02c3ee906626734d7a8c5958e1
BLAKE2b-256 a8d40a02d02e99b1121d4e43fa288d80411949d333399c8c9f7955c82cf8d868

See more details on using hashes here.

Provenance

The following attestation bundles were made for convex2pg-0.1.0.tar.gz:

Publisher: publish.yml on northjosh/convex2pg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file convex2pg-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: convex2pg-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for convex2pg-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b1a5b75200a88597c9114d09e8d79d6e2ca13f0f815a60b22a385f85519ab33
MD5 70c09f7cda43e7b1753853ec6833db17
BLAKE2b-256 1aea516ee76cb1d09329aea49fffcae1519269d22b237b92b2600c6390e3de62

See more details on using hashes here.

Provenance

The following attestation bundles were made for convex2pg-0.1.0-py3-none-any.whl:

Publisher: publish.yml on northjosh/convex2pg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page