Skip to content

Export and import tables, schemas and SQL files - #19

Merged
FabioHAraujo merged 4 commits into
mainfrom
feat/export-import
Oct 23, 2026
Merged

FabioHAraujo merged 4 commits into
mainfrom
feat/export-import

Conversation

@FabioHAraujo

@FabioHAraujo FabioHAraujo commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #10
Closes #11
Closes #12
Closes #13
Closes #14

Problem and resulting behavior

There was no way to move data in or out of LowQuery beyond copying grid rows. This adds export and import that stay simple: few choices, sensible defaults, everything detected that can be.

  • Export… (tables, views, other objects, schemas): format (SQL, CSV, CSV for Excel, JSON) and, for SQL, structure and data / structure / data. Then where to save. A schema becomes one .sql file, or one CSV/JSON per table.
  • Import data… (table) and Import file as a new table… (schema): CSV or JSON with encoding, delimiter and header detected, columns matched by name, spreadsheet-style numbers and dates understood, one transaction. Options: delimiter, header row, replace the rows.
  • Run SQL file… (connection, schema): runs a script with progress, stops at the first error unless unticked, lists failures.

Backend: Session::stream reads rows from each driver's cursor in batches (values in full, not cut to the grid preview) into a channel; transfer/ writes SQL (structure from object_ddl, tables in foreign key order, exact literals per engine, identity handling, generated columns skipped), CSV and JSON, and imports with the same literal writer.

Validation

  • transfer/round_trip.rs on every database in CI: a table with quotes, line breaks, backslashes, accents, binary, JSON, dates, identity and generated columns is exported and loaded back from the SQL script (after dropping it), CSV, CSV for Excel and JSON (after deleting its rows); rows must match exactly, and the identity generator must accept a new row afterwards.
  • Unit tests for literals, CSV parsing, encodings, number/date conversion, type inference and foreign key order; bun test, svelte-check, clippy, fmt.
  • Dialogs checked in the browser with the development mock, and the commands in a debug build of the app against a real SQLite file (SQL, CSV for Excel and JSON exports, schema export to a folder, CSV import back with quotes, accents and NULL intact).

Additional context

Includes the Oracle ORA-01002 fix from #18 (already on main) for the 0.5.2 release. Oracle binary values over 2000 bytes cannot be written as a SQL literal yet; CSV/JSON export them fine.

Rows stream from each driver to the file in batches, with binary values in
full. SQL scripts hold the structure (tables in foreign key order, keys
added at the end) and INSERTs in each database's literals, with identity
handling. Imports detect the encoding, delimiter and header, match columns
by name, read spreadsheet-style numbers and dates, and run in one
transaction. A round trip on every database checks it.
Export… on tables, views, other objects and schemas asks only for the format
(SQL, CSV, CSV for Excel, JSON) and, for SQL, structure, data or both.
Import data… previews the file with columns matched by name and offers the
delimiter, header row and replacing the rows; a file can also become a new
table with inferred types. Run SQL file… runs a script with progress and
stops at the first error unless told otherwise.

Context menus also no longer throw while closing.
@FabioHAraujo
FabioHAraujo marked this pull request as ready for review October 23, 2026 04:28
@FabioHAraujo
FabioHAraujo merged commit 146ff84 into main Oct 23, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant