Setup

Weather data set

Source: Visual Crossing Weather

wget https://blobs.duckdb.org/data/amsterdam-weather.csv

Railway data set

Source: Rijden de Treinen

wget https://blobs.duckdb.org/nl-railway/stations-2022-01.csv
wget https://blobs.duckdb.org/nl-railway/tariff-distances-2022-01.csv
wget https://blobs.duckdb.org/nl-railway/services-2019.csv.gz
wget https://blobs.duckdb.org/nl-railway/services-2020.csv.gz
wget https://blobs.duckdb.org/nl-railway/services-2021.csv.gz
wget https://blobs.duckdb.org/nl-railway/services-2022.csv.gz
wget https://blobs.duckdb.org/nl-railway/services-2023.csv.gz
wget https://blobs.duckdb.org/nl-railway/services-2024-01.csv.gz
wget https://blobs.duckdb.org/nl-railway/services-2024-02.csv.gz
wget https://blobs.duckdb.org/nl-railway/services-2024-03.csv.gz
wget https://blobs.duckdb.org/nl-railway/services-2024-04.csv.gz

VS Code hotkey

Define keyboard shortcut Ctrl + Enter for executing selection in terminal

To use the same editor (VS Code) and the same keyboard shortcut (Ctrl + Enter) to run the active line / selected piece of code (for CLI) or the active cell (for Python notebooks), add the CLI hotkey as follows:

  1. Open Visual Studio Code.

  2. Add a custom shortcut, Ctrl + Enter, which send commands from the editor to the terminal. To do so, open the keyboard shortcuts JSON file (Cmd + Shift + P, Preferences: Open Keyboard Shortcuts (JSON)) and add the following key binding:

    [
        {
            "key": "ctrl+enter",
            "command": "workbench.action.terminal.runSelectedText",
            "when": "!notebookEditorFocused"
        }
    ]
    

    The !notebookEditorFocused condition is important to avoid clashing with VS Code’s Jupyter notebook support, which also uses this hotkey.

  3. Open a terminal by pressing Cmd + Shift + P and selecting Terminal: Create New Terminal.

  4. Start the DuckDB CLI in the terminal (e.g., run duckdb).

  5. Then, select any SQL code and press Ctrl + Enter to send the code to the terminal.

Credit: the initial idea is taken from MotherDuck’s tutorial.