Skip to main content

OSQL Notebooks

An OSQL Notebook is similar to a Jupyter notebook and can be used to get an interactive SA Engine prompt which is really useful during development. It can also be used for writing interactive documentation.

Run SA Engine interactively

You can run SA Engine interactively by opening an OSQL Notebook. This will give you an interactive window with an SA Engine prompt where you can write and execute your queries.

To open an empty OSQL Notebook, select "SA Engine: Create an Interactive OSQL Window" in the Command Pallette (Ctrl+Shift+P).

Open a new interactive OSQL window from the Command Pallette.

At the bottom there is an OSQL prompt where you can type in your queries. The prompt has IntelliSense for OSQL so you get code autocompletion, syntax highlighting, and squiggly red lines for syntax errors. You execute a query by clicking the play button next to the query.

SA Engine prompt in an interactive window.

When you execute a query at the prompt, the query pops up as a code cell in the notebook and the result is displayed beneath the code cell. You can stop the query by clicking the red square at the top left of the code cell, and delete the cell by clicking the trashcan.

A query running in a notebook.

You can use the Up and Down arrow keys to cycle through the history of queries in the prompt.

Write interactive documentation

You can write documentation in the form of OSQL Notebooks. This is useful when you want to share documentation where the user can execute code examples without having to copy and paste them into SA Engine.

OSQL Notebooks are regular Markdown files with OSQL code blocks.

# My OSQL documentation

The following query returns the values 1 to 10:

```osql
select x
from integer x
where x in range(10);
```

To open the file as an OSQL Notebook:

  1. Open the .md file in the editor
  2. Open the Command Pallette (Ctrl+Shift+P) and select "View: Reopen Editor With..."
  3. Select "OSQL Notebook"

Reopen .md file as an OSQL Notebook.

This will display the Markdown file as an OSQL Notebook.

Markdown file displayed as an OSQL Notebook.

You can edit the Markdown cells directly in the notebook view by clicking the pen icon.

Edit Markdown cell in an OSQL Notebook.

The code blocks work as text editors so you can edit code block contents by simply clicking inside the code block. To run code blocks you click the play button next to the code block, or place a cursor in the code block and press Shift+Enter.

Run OSQL code block in an OSQL Notebook.

To switch back to the regular text editor:

  1. Open the Command Pallette (Ctrl+Shift+P) and select "View: Reopen Editor With..."
  2. Select "Text Editor"