PUBLISHED:
CATEGORY: Stripe ▸ Misc
TAGS: postgres

Download your Stripe data to a Postgres database

You can have all your Stripe data as Postgres tables in under a minute with the Table Dog CLI:

Start Postgres

# Version 9.6.23
docker run --platform linux/x86_64 -e POSTGRES_PASSWORD=my-secret-pw -p 5432:5432 -d postgres:9.6.23


# Version 14
docker run --platform linux/x86_64 -e POSTGRES_PASSWORD=my-secret-pw -p 5432:5432 -d postgres:14

Create a config file

Save this to a file called config.json:

{
    "cmd": {
        "fn": "download",
        "args": {
            "from": {
                "stripe": {
                    "secret_key": "sk_test_.. download at https://dashboard.stripe.com/apikeys"
                }
            },
            "to": {
                "postgres": {
                    "addr": {
                        "ip": "127.0.0.1",
                        "port": 5432
                    },
                    "user": "postgres",
                    "pass": "my-secret-pw"
                }
            },
            "options": {
                "watch": true
            }
        }
    },
    "log": "info"
}

Note: This TypeScript file documents all possible CLI options.

Install the tdog CLI

# macOS:
curl -L --output /usr/local/bin/tdog https://github.com/tabledog/tdog-cli/releases/latest/download/tdog-x86_64-apple-darwin
chmod +x /usr/local/bin/tdog

Run tdog to download all of your tables

This will also poll the Stripe /events API and apply changes with less than a second delay.

tdog --json-file config.json