Intro
Before we can start learning KDB/Q we first need to have a running version of q installed. Let's kickstart our journey!
Please note, I will only cover the installation for personal use. If you are trying to install a commercial version of KDB/Q, please follow the guide on code.kx.com.
Getting Started
The easiest way to install KDB/Q is to head over to code.kx.com and follow the installation guide here. However, for simplicity I will also include the steps in this blog.
At the time of writing, KX offers a 64-bit Personal Edition for non-commerical use. This version of KDB/Q is not licenced for cloud usage and requires an internet connection to be run.
Step 1: Downloading KDB/Q
Navigate to code.kx.com
and download the current version of KDB/Q from here. KX offers a version for all three main operating systems: Linux, macOS or Winwos.
After completing the download form, the download should start and you should receive an email with your kc.lic
licence file
Step 2: Unzip your download
I will presume that you will be installing KDB/Q in your HOME
directory on Linux or macOS; or in C:\
on Windows, and subsequently configure the environment variable QHOME
accordingly.
- Linux
- macOS
- Windows
QHOME should be set to ~/q
QHOME should be set to ~/q
QHOME should be set to c:\q
You can install kdb+ anywhere as long as you set the path in QHOME.
Open a command shell and cd
to your downloads directory.
Unzip the downloaded ZIP and create a folder q
in your install location.
- Linux
- macOS
- Windows
unzip l64.zip -d $HOME/q
unzip m64.zip -d $HOME/q
Expand-Archive w64.zip -DestinationPath C:\q
For Linux and macOS users, the rlwrap command enhances the q session by enabling the use of the Up arrow to recall previous expressions. This feature is highly advantageous and makes you more productive. I highly recommend its installation. Unwrapping rlwrap
Ask for its version number: rlwrap -v
. If you see one, rlwrap
is already installed. Otherwise, you will see rlwrap: command not found
.
Install rlwrap
using your package manager. (Common package managers: apt
, dnf
and yum
for Linux; Homebrew and MacPorts for macOS.)
Step 3: Install the licence file
As mentioned earlier, you should have received an email from KX
with your personal kc.lic
file which you have to put in your QHOME
directory
Your QHOME
directory should then look like the following:
- Linux
- macOS
- Windows
|- kc.lic
|- l64
- q
|- q.k
|- kc.lic
|- m64
- q
|- q.k
|- kc.lic
|- w64
- q
|- q.k
KDB/Q is looking for a licence file in QHOME
. You can change the location of your licence file by setting the path to the licence file in the evironment variable QLIC
. You can find more information here
Step 4: Start a KDB/Q process
In order to confirm that KDB/Q is working launch your first q session. cd
into your QHOME
directory and lanch the application
- Linux
- macOS
- Windows
q/l64/q
q/m64/q
c:\g\w64\q
Your q
session should start with a banner like this
KDB+ 4.0 2023.01.20 Copyright (C) 1993-2023 Kx Systems
m64/ 4(24)core 8192MB Alexander alexanders-mbp 192.168.1.102 EXPIRE 2024.02.17 your.email@gmail.com KOD #5012923
q)
Step 5: [Optional] Create an alias
Creating an alias for q
allows you to start a KDB/Q session without having to specify the path each time. So let's do that
- Linux
- macOS
- Windows
1. Open your ~/.bash_profile in a text editor and add the following line
2. alias q='QHOME=~/q rlwrap -r ~/q/l64/q'
3. In the command shell, load the updated profile with 'source .bash_profile'
1. Open your ~/.zshrc file in a text editor and add the following line
2. alias q='QHOME=~/q rlwrap -r ~/q/m64/q'
3. In the command shell, load the updated profile with 'source ~/.zshrc'
In the command shell run the following commands:
1. setx QHOME "C:\q"
2. setx PATH "%PATH%;C:\q\w64"