Import & Export
Export
From the data view, press Alt+m (or open the actions palette with Ctrl+Space) to export the current table or query results.
Supported formats
| Format | Extension | Notes |
|---|---|---|
| CSV | .csv | Comma-separated, RFC 4180 |
| JSON | .json | Array of row objects |
| SQL | .sql | INSERT statements |
| Markdown | .md | GFM table |
| Text | .txt | Space-delimited aligned columns |
The export dialog lets you choose the format and toggle options:
- Include headers — add a header row (CSV, Markdown, Text)
- Pretty print — indent JSON output
- Compress — gzip the output file (available for all formats)
The file is saved to your current working directory by default.
Import CSV
Press Alt+i from anywhere in the main view (or use the actions palette) to import a CSV file into the current table.
vi-sql will:
- Read the CSV header row and map columns by name
- Show a preview of the first rows
- Ask for confirmation before inserting
Requirements
- The CSV must have a header row
- Column names must match the target table's columns (extra columns are ignored)
- The target table must already exist
Example
sh
# CSV file: users.csv
id,name,email
1,Alice,alice@example.com
2,Bob,bob@example.comImport into the users table → vi-sql runs:
sql
INSERT INTO users (id, name, email) VALUES
(1, 'Alice', 'alice@example.com'),
(2, 'Bob', 'bob@example.com');