rango import

Imports data from JSON or CSV into the database.

Usage

# Import from JSON (format auto-detected from extension)
rango import data.json

# Import into a specific table
rango import users.json --table user

# Import CSV
rango import users.csv --table user

# Replace existing rows on conflict
rango import fixtures.json --replace

# Explicit format
rango import data --format json --table users

Options

OptionDefaultDescription
--tablefrom __table fieldTarget table. Required for a single-table export (rango export --table x) and for CSV, which carry no __table; without it import stops with an error asking for it.
--formatauto-detectedjson or csv
--replaceskipReplace existing rows on conflict
--database-urlDATABASE_URLDatabase connection URL

Conflict behavior

ModeSQLUse case
Default (skip)INSERT OR IGNORE / ON CONFLICT DO NOTHINGLoad fixtures without overwriting
--replaceINSERT OR REPLACE / ON CONFLICT DO UPDATESync/upsert data

JSON format

[
  { "id": "abc-123", "email": "alice@example.com", "active": true },
  { "id": "def-456", "email": "bob@example.com", "active": false }
]

With __table (multi-table import without --table):

[
  { "__table": "user", "id": "...", "email": "alice@example.com" },
  { "__table": "post", "id": "...", "title": "Hello" }
]

Fixtures / loaddata

rango import is Rango's equivalent of Django's loaddata. Use it to seed development databases:

# Export production data (sanitized)
DATABASE_URL=$PROD_URL rango export --table user --output fixtures/users.json

# Load into dev
DATABASE_URL=sqlite://dev.db rango import fixtures/users.json