pg2sqlite

command
v1.833.387 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Command pg2sqlite migrates cloud-api's dbx-managed Postgres database to a SQLite file. cloud-api uses raw dbx queries (not ORM struct sync), so the canonical schema lives in postgres only. This tool translates the live postgres schema + data into a SQLite file the cloud-api binary can open with driverName=sqlite (the hanzoai/sqlite driver, linked platform-wide).

Usage:

pg2sqlite -src "user=hanzo password=... host=postgres port=5432 dbname=hanzo_cloud sslmode=disable" \
          -dst /tmp/cloud-staging.db

Strategy:

  1. Open source postgres via lib/pq, destination sqlite via hanzoai/sqlite.
  2. Discover schema from information_schema (no pg_dump dependency).
  3. Translate per-column types to SQLite equivalents.
  4. Per-table CREATE TABLE on destination using composite PK from information_schema.table_constraints (the cloud-api convention is PRIMARY KEY (owner, name) on every table except `record` which uses a synthetic INTEGER id).
  5. Stream rows: SELECT * FROM source → INSERT into dest with parameter binding (nil → NULL, []byte → BLOB, time.Time → RFC3339).
  6. Emit a per-table row-count report so the operator can verify parity before flipping driverName.

Mirrors the IAM pg2sqlite design (~/work/hanzo/iam/cmd/pg2sqlite/main.go) but works without xorm because cloud-api never adopted xorm.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL