Favorites & History

Save the queries you reuse, find every query you've run, and work with .sql files on disk.

Mantidb keeps track of your SQL in three ways: favorites are queries you save on purpose, history is a record of every query you run, and SQL files are ordinary .sql files you open and save from disk.

Save a favorite

  1. Write the query in a query tab.
  2. Press ⌘D (Query ▸ Save as Favorite…) or click the ★ button in the query toolbar.
  3. In the Save as Favorite popover, fill in:
    • Name — the name of the favorite.
    • Folder — No Folder, one of your existing folders, or New Folder… (then type a Folder name).
  4. Click Save.

If a favorite with the same name already exists in that folder, the button becomes Replace, so you can overwrite it on purpose.

The Queries tab

Your favorites are listed in the Queries tab of the sidebar, grouped in folders.

  • Click a favorite to open it in a new query tab. It isn't run until you run it.
  • Use the search field to find a favorite by name, folder or SQL text.
  • Click New Folder to create a folder.

Right-click a folder or a favorite for more options:

ItemMenu
FolderRename Folder…, Delete Folder…
FavoriteOpen, Rename…, Move to ▸ (No Folder or a folder), Copy SQL, Delete…

You can also open a favorite from anywhere with ⌘K — see Open Anything.

Where favorites are stored

Each favorite is a plain .sql file in ~/Library/Application Support/Mantidb/Favorite/, either at the top level or inside one folder (Favorite/<folder>/<name>.sql). Folders are one level deep.

  • Favorites are shared across all your connections, so a query you save in one window is available in every other.
  • Because they are ordinary files, you can edit, copy or version them with any tool.

History

Every query that runs is recorded — from the SQL editor, and also from the AI Assistant, plugins and tools such as killing a session in the Process List.

  • The History tab in the sidebar shows the newest 200 queries for the current connection. Each entry shows the first lines of the SQL, the date and time, and how long it took.
  • Right-click an entry for Open in Query Tab or Copy SQL.
  • Press ⌘K to search your history together with tables and favorites. History opens in a new query tab without running.

When nothing has run yet, the tab shows "No queries yet".

Where history is stored

History is saved as plain SQL, one file per connection and day:

~/Library/Application Support/Mantidb/History/<connection-id>/<yyyy-MM-dd>.sql

Each query is preceded by a comment with its date and duration, so the files are easy to read or search with any text tool. The sidebar shows the latest 200 entries, but older queries remain in these files.

SQL files

You can open and save .sql files directly in a query tab.

Open a file

  • File ▸ Open SQL File… (⌘O). You can select several files at once.
  • Double-click a .sql file in Finder.
  • Drag a .sql file onto the Mantidb icon in the Dock.

The file opens in a new query tab of the frontmost connection window, and the tab is named after the file. If no connection window is open, the welcome window asks you to Choose a connection for “file.sql” and opens the file in the first connection you connect to.

Save a file

  • ⌘S saves the file. In a query tab, File ▸ Commit Changes becomes Save.
  • The first time you save a new query, Mantidb asks where to put it.
  • File ▸ Save As… (⇧⌘S) saves a copy under a new name or location.

Encodings and limits

  • Mantidb keeps the file's encoding and line endings when you save. UTF-8 and UTF-16 (with or without a BOM) are supported, with Windows-1252 as a fallback.
  • Binary files and files larger than 20 MB can't be opened.

Unsaved changes

A • in the tab title means the file has edits that haven't been saved. Closing the window or quitting Mantidb asks before you lose them ("Close “x” without saving?").

When a connection's tabs are restored, .sql files are read again from disk, so unsaved edits are not kept. Save before closing if you want to keep them.