Scratchpad Panel¶
This page describes the Scratchpad panel in the Query window, and how to use it to run ad hoc queries against your database or execute arbitrary q and Python code.
For an introduction to what the Scratchpad is and what you can do with it, see the Scratchpad Overview.
Results of your queries can be viewed in the output panel at the bottom of the screen.
If these panels are not visible, click View, in the top left-hand corner, and toggle Scratchpad Panel and/or Output Panel to display them.

Scratchpad Layout¶
The Scratchpad is the top right-hand section of the Query window.
If this panel is not visible, click View, in the top of the window, and toggle Scratchpad Panel to display it.

This panel has the following elements:
-
Editor: A scrollable window where you enter your code. The two tabs at the top right-hand corner of the window allow you to toggle between q and Python editors.
-
Run All: Runs all the code in the editor. The output is displayed in the tabs below the editor. To run only the current line or highlighted selection, use Ctrl + D or Ctrl + Enter on Windows, or ⌘Enter or ⌘D on macOS.
-
Reset and Cancel: Located in the bottom-left corner of the window. Use them to restart your Scratchpad or stop a running query. Refer to Cancel, reset, and timeouts.
Hotkey for quick access to documentation
The scratchpad supports using the Ctrl+/ hotkey to open documentation related to the selected operators, keywords, and values within single-letter namespaces.
Firefox Users
If you’re having trouble scrolling in the Scratchpad while using Firefox, make sure that scrollbars are set to always be visible.
Create ad hoc queries in the Scratchpad panel¶
To perform an ad hoc query using the Scratchpad:
- Create a query using the Query panel.
-
When analyzing the data retrieved from your kdb Insights Enterprise database, you can use either q or Python.
Select the q or Python tab on the Scratchpad panel, depending on your language preference, and enter your query.
The following example shows a query which returns the results to an output variable called weather. This variable is then used in the q query in the Scratchpad to perform a further ad hoc query to refine the results.

-
Click Run All.
- View and analyze the results in the output panel.
Running Queries
When you run a selected line, its context comes from the preceding lines, as with \d .myContext or system "d .myContext". The global context is used in the absence of a preceding line.
Read more about using q and Python in your queries.
VS Code Integration¶
If you work with existing code bases or versioned code, or want to organize your code, the kdb Visual Studio Code Extension offers an alternative to the Scratchpad panel in the web interface. The extension is separate from the panel: it connects to the same q Scratchpad process that the panel uses, so all variables are shared between the two. It supports evaluating q (from .q, or .quke files) or Python (from .py files). The same options for querying the database are available from the extension.
Next steps¶
- View results in the output panel
- Cancel or reset a query, and set timeouts
- Perform further analysis and development in the Scratchpad using q or Python
- Use Scratchpad query APIs to interact with the database
- Manage your Scratchpad
- Create advanced Visualizations