Help › Write SQL
Open and save SQL files
Open .sql files from disk in query tabs, save them back, save any tab as a new file, and what happens when a file changed on disk.
Querlyn 0.1.0 is not released yet. This help describes it ahead of release.
A query tab can be a file on your disk. You open it, edit it, run it and save it back, as in a text editor.
A tab has one home: a file on disk, a saved query inside Querlyn, or neither. For saved queries see Keep queries as saved queries.
Open a file
Any of these opens a file in a query tab titled with the file's name:
- Choose (⌘O on macOS or Ctrl+O on Windows and Linux) and pick one or several files.
- Drag files from the Finder onto the Querlyn window.
- In the Finder, use Open With on a
.sqlfile and choose Querlyn. Installing Querlyn does not make it the default application for.sqlfiles.
The first file opens in the tab you are in, if that tab is new and empty; each other file gets a tab of its own. A file that is already open is shown again and not opened twice.
A file does not remember a connection. Choose one in the bar above the editor; see Choose a tab's connection and database.
A .js file opens in a query tab like any other file. On a MongoDB
connection its tab starts in script mode, where the whole file runs as
one mongosh script; see
Run a MongoDB script in mongosh.
Save
| Command | What it does |
|---|---|
| (⌘S on macOS or Ctrl+S on Windows and Linux) | Writes the tab back to its file. |
| (⇧⌘S on macOS or Ctrl+Shift+S on Windows and Linux) | Writes any query tab to a new file. That file becomes the tab's home. |
| Keeps the tab as a saved query inside Querlyn instead. |
In a tab that has no home yet, Save asks for a name to keep the tab as a saved query. The dialog has a Save as File… button if you want a file instead.
A tab with changes that are not saved has a dot on it. The dot goes away when you save, and also when you undo your way back to the text as it was saved.
Close a tab with unsaved changes
When you close a file's tab that has changes, Querlyn asks Save changes to and the file's name:
| Button | Key | What it does |
|---|---|---|
| Save | ↩ on macOS or Enter on Windows and Linux | Writes the file, then closes the tab. If writing fails, the tab stays open. |
| Don't Save | Shown in the button's tooltip | Closes the tab and drops the changes. |
| Cancel | ⎋ on macOS or Esc on Windows and Linux | Leaves the tab open. |
Quitting asks once for all the tabs with unsaved changes.
Warning: This question is asked for files and saved queries only. A new tab that was never saved closes without a question, and its SQL is gone. Save what you want to keep. What you ran is still in the query history.
When the file changed on disk
Querlyn does not watch files, and never reloads one by itself. It notices when you save: if another program changed the file since you opened or saved it, Querlyn asks before writing.
| Button | What it does |
|---|---|
| Overwrite | Writes your text over the file. ↩ on macOS or Enter on Windows and Linux does not choose this. |
| Reload | Drops your changes and loads the file again. |
| Cancel | Leaves both as they are. |
If the file was deleted meanwhile, saving writes it again without asking.
How files are read and written
- UTF-8 only. A file in another encoding is not opened; the message says so, and names UTF-16 or UTF-32 when the file says it is one of those. A UTF-8 byte-order mark is kept.
- Line endings are kept. A file with Windows line endings is saved with them. A file that mixes the two kinds is saved with the more frequent one throughout, and Querlyn tells you so when it opens the file. A new file gets LF line endings.
- At most 100 MB. A larger file is not opened. To run a large dump, use Back up and restore a database or the database's own program.
- Saved in place. Querlyn writes into the existing file, so its permissions, Finder tags and links stay as they are. If writing fails half-way, the file can be incomplete; the message says so and your text stays in the tab, so you can save again.
What is not offered
- A list of recent files, and reopening your query tabs when Querlyn starts. Querlyn starts with one empty query tab (and the table tabs that were open).
- Automatic saving, and going back to the saved version of a file.
- Showing a tab's file in the Finder.
Help for Querlyn 0.1.0. All help topics