REPL
This page provides an overview of the REPL and describes how to use it for interactive q development within the kdb Visual Studio Code Extension.
REPL stands for Read-Eval-Print Loop, and is an interactive programming environment used in many languages. REPL is particularly useful for interactive development, debugging, and testing because it allows you to write and run code snippets in real-time, seeing immediate feedback.
The REPL is the primary mechanism for running and testing q code in the kdb Visual Studio Code Extension. It provides an interactive interface to execute commands directly against the KDB-X runtime.
Start the REPL
You can start a REPL session from the Command Palette by searching for >repl.

Once started:
- A terminal window opens containing the active q session.
- The session persists until explicitly closed.
- Any variables, functions, or tables created remain available for future commands.
Execute q files
To execute a q file in the REPL:
- Click Choose Connection
- Select REPL from the list
- Execute your q file
The results are shown in the terminal and you can continue to work either in your q file or directly in the terminal.
Refer to the REPL shortcuts table for information on what keyboard shortcuts you can use.
Benefits of using REPL
A REPL gives you a tight feedback loop, stateful context, and guardrails. You learn faster, debug quicker, and ship with fewer mistakes.
Key benefits include:
-
Rapid iteration with stateful sessions. Execute commands and receive immediate feedback while maintaining session state across operations. This enables faster development cycles with reduced boilerplate.
-
Safe and efficient troubleshooting. Experiment within transactions and roll back changes as needed. Quickly isolate and resolve issues by modifying and re-running queries in real time.
-
In-context exploration and optimization. Access schema details, autocomplete, and performance insights directly within the REPL, supporting informed tuning and discovery.
-
Streamlined workflow and reusability. Minimize context switching by staying within a single interface. Use command history as a living notebook to document, replay, or convert workflows into scripts.
-
Smooth transition to production and built-in safeguards. Validate logic in the REPL before promoting queries to production. Features like autocommit off, role switching, and environment prompts help prevent unintended changes.
Use PyKX within REPL
The kdb Visual Studio Code Extension allows you to integrate PyKX directly within the REPL environment. When KDB-X is installed through VS Code, PyKX support is automatically available within the REPL environment, enabling you to switch between q, Python and SQL contexts for data analysis, visualization, or model development.
Refer to the PyKX within REPL instructions for details on how to get started and use PyKX within REPL.
Note
The REPL automatically inherits the active Python virtual environment (venv) from the Python extension in VS Code. If you switch Python interpreters and restart the REPL, it will use the latest interpreter selected in VS Code.
Supported file types
In addition to q and Python files, SQL files are also supported for execution within REPL. Refer to the supported execution types table for more details.
Next steps
- Learn more about executing code in the kdb Visual Studio Code Extension