kdb Visual Studio Code extensionThis is a companion extension for kdb developers to edit q files, connect to kdb processes, and run queries. This VS Code extension can be used alongside kdb Insights Enterprise when using a shared kdb process. Please use vscode-questions@kx.com to raise any questions or feedback. Contents
Why q for VS Code?With the kdb VS Code extension you can:
Get startedIf you have an existing q installation, you will see the message If you are new to q, you can install q with the kdb VS Code extension; see install q. Install qStep 1: Download the latest version of kdb+. Different versions of kdb+ are available, and the version you download will determine the supported features in VS Code:
Contact licadmin@kx.com for commercial kdb licensing. Step 2: After registering, you will receive an email with a link to download an installation file. Extract the file to a directory; instructions are available for Linux, macOS and Windows.
Step 3: The welcome email will also have your kdb, Note: If your kdb license is stored outside of your q (
Install q with VS Code.You can install q from the VS Code extension. You still need to register for kdb Insights Personal Edition to obtain a license and VS Code will guide you through steps to install. The license will be incorporated as part of the kdb VS Code extension, although a Step 1: Click Step 2: If you have already registered for kdb+ or kdb Insights, then choose Step 3: With the license secured, you can then link this to VS Code by either The base64 encoded license string can be found in the welcome email received after registration, under the download link for the license file. The Step 4: Set a If q is installed at To finish, a prompt is offered with an opt-in to receive a newsletter. ConnectionsThe kdb VS Code extension allows you to connect VS Code to a q process; this can be remote, referred to as an unmanaged q session or a managed q session, which uses the q installed as part of the kdb VS Code extension installation. It runs a child q process from within the extension and is fully managed by the extension. Only one connection can be active at any given time. Bundled qThis runs a q session using the existing kdb installed as part of the kdb VS Code extension. Step 1: Click connect to kdb server or Add new connection from the CONNECTIONS context menu. Step 2: A new window will open with the type of connection you desire to add, Select Bundled q. Step 3: The server name / alias will already be set as Step 4: The connection address will be already be set as Step 5: Set the port for the kdb server. Ensure the port used doesn't conflict with any other running q process; e.g. 5002
Step 6: Click Create connection to confirm the connection creation Step 7: Right-click the q bundled process listed under KX:CONNECTIONS, and click Start q process. Step 8: From the same right-click menu, click Connect kdb server. This connects to the child q process running inside the kdb VS Code extension. If you close the extension, the connection to the child q process also closes. My qStep 1: Identify the remote location of a running process. The hostname and port will be required along with any authentication information. Step 2: Within the kdb VS Code extension, click connect to kdb server, or *Add new connection** from the *CONNECTIONS* context menu. Step 3: A new window will open with the type of connection you desire to add, Select My q. Step 4: Assign a server name / alias. The server name selected cannot be Step 5: Set the connection address or ip address of the kdb server; e.g. localhost. Step 6: Set the port used by the kdb server; e.g. 5001.
Step 7: If authentication is needed, fill in the username and password fields, otherwise, leave these fields blank Step 8: If TLS is enabled, check the checkbox.
Step 9: Click Create connection to confirm the connection creation Upon completion, the localhost connection appears under KX:CONNECTIONS in the left hand panel. Insights ConnectionFor kdb Insights Enterprise, the kdb VS Code extension is using a shared kdb process. Unlike for a managed q session, you must have kdb Insights Enterprise Personal Edition running before using these connections. Step 1: Click connect to kdb server. Step 2: A new window will open with the type of connection you desire to add, Select Insights connection. Step 3: Create a server name / alias; this can be any name, aside from Step 4: Set the hostname. This is the remote address of your kdb Insights Enterprise deployment: e.g Step 5: Click Create connection to confirm the connection creation Step 6: The kdb Insights Enterprise connection is listed under KX:Connections, with its own icon. Right-click the connection and Connect to Insights Step 7: The kdb VS Code extension runs an authentication step with the remote kdb Insights Enterprise process; sign-in to kdb Insights Enterprise. After a successful connection to a kdb Insights Enterprise process, a new DATA SOURCES panel will become available in the kdb VS Code extension. Once connected to a q process, go to execute code. kdb language serverA kdb language server is bundled with the kdb VS Code extension. It offers various common features to aid in the development of kdb code within VS Code, including: Syntax highlightingThe extension provides keyword syntax highlighting, comments and linting help. Linting is supported for assignment to reserved words and literals, unused arguments and variables, line length, deprecated date time, too many globals, locals and constants. More linter rules will be supported for future releases. Code navigationWhile developing q scripts, the kdb VS Code extension supports:
Code Completion
Rename SymbolSupports renaming symbols in text editor. Right-click and select "Rename Symbol" on any identifier and extension will rename it. Execute codeLeaning on VS Code's extensive integrations with SCMs, all code is typically stored and loaded into a VS Code workspace. From there, the kdb VS Code extension allows you execute code against both kdb processes, and kdb Insights Enterprise endpoints. kdb process executing codeThere are three options available from the right-click menu for executing code:
Insights query executionkdb Insights Enterprise offers enhanced connectivity and enterprise level API endpoints, providing additional means to query data and interact with kdb Insights Enterprise that are not available with standard kdb processes. You must have an instance of kdb Insights Enterprise running, and have created a connection within the kdb VS Code extension. Similarly, you can execute arbitrary code against kdb Insights Enterprise. The code is executed on a user-specific sandbox process within the kdb Insights Enterprise deploy. The sandbox is instanciated upon the first request to execute code when connected to a kdb Insights Enterprise connection. It remains active until timed out or until you log out. Data sourceskdb Insights Enterprise supports the use of data sources, where you can build a query within VS Code and run it against the kdb Insights Enterprise API endpoints. The UI helps you to build a query based on the available API on your instance of kdb Insights Enterprise, parameterize it and return the data results to the output or kdb results window. To create a data source:
To run a data source, click 'Run' and the results populate the output and kdb results windows. In addition to API queries, if the query environment is enabled on the deployed instance of kdb Insights Enterprise, qSQL and SQL queries can be used within a data source with the appropriate parameterization. Populate scratchpadYou can use a data source to populate a scratchpad with a dataset, allowing you to build complex APIs and pipelines within VS Code and kdb Insights Enterprise. To do this:
View resultsAll query executions happen remotely from the kdb VS Code extension either against a running q process or against an instance of kdb Insights Enterprise. The results, successful or otherwise, are returned to VS Code as:
q REPLq REPL can be started from the command prompt by searching "q REPL". SettingsTo update kdb VS Code settings, search for
Insights Enterprise Connections for Explorer
Servers
ShortcutsFor Windows
For MacOS
|