Skip to main content
Docs/CSV Import
DocsCSV Import
Free

CSV Import

window.genmb.import validates and inserts CSV rows into your app PostgreSQL tables. Dry-run for errors first, commit up to 500 rows in one call. Optional upsert by unique key.

Dry Run

Validate rows against your target table schema without writing. Returns {valid, errors:[{row, field, message}]}.

const result = await window.genmb.import.dryRun({
  table: 'customers',
  rows: parsedCsvRows,
})
if (result.errors.length) {
  console.log('Fix these:', result.errors)
}
Always run a dry-run on user-uploaded CSV before showing a success state. Bad data is the rule, not the exception.

Commit

When dry-run is clean (or you accept partial), call commit:

const result = await window.genmb.import.commit({
  table: 'customers',
  rows: cleanedRows,
})
// result: { inserted, updated, errors }
A single commit call writes up to 500 rows. For larger files, chunk client-side and call commit per chunk.

Upsert

Pass uniqueKey to upsert instead of pure insert. Rows matching an existing record by that column are updated; the rest are inserted.

await window.genmb.import.commit({
  table: 'customers',
  rows,
  uniqueKey: 'email',     // existing rows matched by email get updated
})

Security

  • Table names are coerced through a safe-identifier guard before any SQL runs.
  • Inserts use parameterized SQL (asyncpg $1, $2, ...). No string interpolation of user data.
  • The signed-in end-user is resolved from the session cookie; if the target schema has a userId column, it is stamped on every row.

Limits

  • 500 rows per commit call.
  • Schema must match the codegen-provisioned table (column names + types).
  • Standard write rate limit on DataConnect (30 writes / minute / app).
  • Available on all plans, including Free.

For non-CSV ingest (PDF / Excel / Doc AI), see Business Data Ingest.

FAQs

What is the CSV Import SDK?
window.genmb.import validates and inserts CSV rows into your app's PostgreSQL tables. It runs a dry-run first to surface row-level errors, then commits up to 500 rows in a single call.
How does upsert work?
Pass uniqueKey: "email" (or whatever column) to commit. Rows that match an existing record by that key are updated; rows without a match are inserted.
What if my CSV does not match the schema?
Dry-run returns a per-row, per-field error list so you can fix the source file before committing. The commit call also returns errors for any row that failed validation at commit time.
Is the user that uploaded stamped on rows?
If the target schema has a userId column, the SDK populates it from the signed-in end-user session automatically.

Ready to build?

Create your first app for free, no credit card required.