Help › Import, export and back up
Import data from a file
Load rows from a CSV, TSV, JSON or Excel file into a table that exists or into a new one, all or nothing, and find the row that stopped an import.
Querlyn 0.1.0 is not released yet. This help describes it ahead of release.
Querlyn loads the rows of a file into a table. An import is all or nothing: if one row cannot be loaded, or you cancel, no row is kept.
It reads CSV, TSV, JSON (an array of objects), JSON Lines and Excel
(.xlsx) files, on every database Querlyn supports.
Start an import
The connection must be connected.
| To import into | Do this |
|---|---|
| A table that exists | Select the table in the sidebar and choose , or right-click it and choose Import Data…. |
| A new table | Select a connection, database or schema and choose , or right-click and choose Import Data into New Table…. |
You cannot import into a view.
The import dialog has four steps: File, Table, Review and Import. Next and Back move between them; when Next is disabled, a line says what is missing.
Step 1: the file
Choose Choose File… and pick the file. Querlyn reads the start of it, works out how it is written, and shows its first rows as it reads them. A line says what it found, for example "Detected: UTF-8, comma-separated. Change any choice if it reads wrong." If the preview looks wrong, change the choices:
| Choice | Options |
|---|---|
| Format | CSV, TSV, JSON, JSON Lines, Excel |
| First row holds column names | On or off |
| Delimiter | Comma, Semicolon, Tab, Pipe |
| Quote | Double, single or None |
| Encoding | UTF-8, UTF-16 LE, UTF-16 BE, Latin-1 (Windows-1252) |
| Sheet | For Excel: which sheet. The first one at the start. |
| Empty fields | What an empty field in a CSV file means: NULL (at the start), Empty text, or NULL unless the field is written as two quotes |
| NULL text | A text that means NULL: None, NULL, \N, or Custom |
| Dates | ISO (2024-10-05), DD/MM/YYYY, MM/DD/YYYY, DD.MM.YYYY, or Custom with a format of your own |
| Binary as | How binary values are written in the file: Hex or Base64 |
The dialog does not remember these choices for the next import.
Step 2: the table
Into a table that exists
Querlyn matches the file's columns to the table's columns by name, ignoring upper and lower case, spaces, hyphens and dots. For each column of the table you can choose another column of the file, or Default to let the database fill it.
- A column the database fills itself is shown as Filled by the database and cannot take values from the file.
- A column that does not allow NULL and has no default must get a column of the file.
- Columns of the file that go nowhere are listed after "Not imported:".
Into a new table
Querlyn suggests a name for the table from the file's name, a column for
each column of the file, and a type for each from the file's first rows.
Change any name or type, and clear NULL for a column that must always
have a value. The CREATE TABLE statement is shown as it will run.
The types are a suggestion from the first 100 rows only. A column of numbers with a text further down in the file needs a text type.
Step 3: review, and import
The review names the file, the table and the connection. Querlyn converts the first rows as a trial and lists what would not import as it is, so that you can go back and change a choice.
Choose Import. On a Production connection Querlyn asks first; the question is titled Import into Production?. On other connections an import does not ask, because it only adds rows.
While it runs, the dialog shows rows imported and the rate. Hide keeps it running: its progress is then in the status bar, and a click there, or , brings the dialog back. Cancel Import () stops it, and nothing is imported.
One import runs at a time. It uses a session of its own, so your query tabs and their transactions are not touched.
When a row cannot be imported
The import stops and nothing is kept. The result lists the problems with the line of the file each is on, up to the first 100.
- Copy Errors copies the list ().
- Back returns to the review, where you can change a choice, for example the date format, and try again.
What counts as a problem:
- A value that does not fit its column: text in a number column, a number too large, a date that is not a date.
- A row the database rejects, for example a duplicate key or a missing value in a column that needs one.
- A row with more fields than the header has, or a JSON record with a key that is no column. Nothing is dropped silently.
A row with fewer fields than the header is accepted: the missing fields are NULL. Blank lines are skipped.
How values are read
- Text is kept exactly as it is in the file. Other values are trimmed, and a value of spaces only is NULL.
- Decimal numbers are kept exactly.
- A time with an offset, going into a column without a time zone, keeps
its clock time:
2024-10-05T12:00:00+02:00is stored as12:00:00. - In Excel files, empty cells are NULL, date cells become dates, rows without values are skipped, and a cell showing an Excel error fails its row.
What depends on the database
On most databases the whole import is one transaction. Where that is not possible, Querlyn says so in the review:
| Database | What differs |
|---|---|
| MySQL, MariaDB | A new table is created first and dropped again if the import fails. Tables that cannot roll back, such as MyISAM tables, are refused. Values that do not fit fail the import; they are not cut to fit. |
| Oracle Database | A new table is created first and dropped again if the import fails. |
| ClickHouse | Rows are first loaded into a temporary table and then moved into the target in one step. An error before that step leaves the target untouched. An error during it can leave some rows in a table that has several partitions; the result then says so. |
| Snowflake | Rows are first loaded into a temporary table and then moved into the target in one step. |
| BigQuery | A new table is created first and dropped again if the import fails. Rows go in INSERT statements of up to 500 rows with bound values, in a transaction. |
| Amazon Redshift | SUPER and VARBYTE columns cannot be imported into. |
A read-only connection refuses imports; see Read-only connections.
To write rows to a file, see Export results to a file. To query a file without loading it into one of your databases, open it in the scratch. To move rows from one database to another, see Copy tables between connections.
Help for Querlyn 0.1.0. All help topics