Installing kdb+¶
You can run kdb+ on Linux, macOS, or Windows
Step 1: Download¶
The 64-bit kdb+ Personal Edition interpreter is licensed for non-commercial use. It is not licensed for use on cloud servers.
The provided license-key file (kc.lic
) requires an always-on Internet connection.
Commercial versions of kdb+ are available to customers from downloads.kx.com. Credentials are available from the customer's Designated Contacts.
Requires a 64-bit interpreter and a k4.lic
or kc.lic
license-key file
OR
a 32-bit interpreter.
32-bit applications will not run in macOS 10.15+ (Catalina and later)
Internal distribution at customer sites
Most customers download the latest release of kdb+ (along with the accompanying README.txt
, the detailed change list) and make a limited number of approved kdb+ versions available from a central file server.
Designated Contacts should encourage developers to keep production systems up to date with these versions of kdb+. This can greatly simplify development, deployment and debugging.
Platforms and versions
The names of the ZIPs denote the platform: l64.zip
– 64-bit Linux; w32.zip
– 32-bit Windows, etc. m64 contains a universal binary suitable for both Intel and Apple Silicon Macs. l64 contains the Linux x86 build, with l64arm containing the Linux build suitable for ARM processors.
Numerical release versions of the form 3.5, or 4.0 are production code. Versions of kdb+ with a trailing t
in the name such as 3.7t
are test versions and are neither intended nor supported for production use.
Step 2: Unzip your download¶
Here we assume you install kdb+ in your HOME
directory on Linux or macOS; or in C:\
on Windows, and set the environment variable QHOME
accordingly.
os QHOME
---------------
Linux ~/q
macOS ~/q
Windows 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 to produce a folder q
in your install location.
unzip l64.zip -d $HOME/q
unzip m64.zip -d $HOME/q
Expand-Archive w64.zip -DestinationPath C:\q
How to run 32-bit kdb+ on 64-bit Linux
Use the uname -m
command to determine whether your machine is using the 32-bit or 64-bit Linux distribution.
If the result is
i686
ori386
or similar, you are running a 32-bit Linux distributionx86_64
, you are running a 64-bit Linux distribution
To install 32-bit kdb+ on a 64-bit Linux distribution, you need a 32-bit library. Use your usual package manager to install i686 or i386: for example, sudo apt-get install libc6-i386
.
Step 3: Install the license file¶
If you have a license file, k4.lic
or kc.lic
, put it in the QHOME
directory.
Your QHOME
directory will then contain:
├── kc.lic
├── l64/
│ └── q
└── q.k
├── kc.lic
├── m64/
│ └── q
└── q.k
├── kc.lic
├── w64/
│ └── q
└── q.k
(32-bit versions have 32
in the folder name instead of 64
.)
kdb+ looks for a license file in QHOME
. To keep your license file elsewhere, set its path in environment variable QLIC
.
Step 4: Confirm success¶
Confirm kdb+ is working: launch your first q session.
cd
q/l64/q
cd
spctl --add q/m64/q
xattr -d com.apple.quarantine q/m64/q
q/m64/q
Authorizing macOS to run kdb+
MacOS Catalina (10.15) introduced tighter security. It may display a warning that it does not recognize the software.
If the spctl
and xattr
commands above have not authorized the OS to run q, open System Preferences > Security & Privacy.
You should see a notification that q has been blocked – and a button to override the block.
c:\q\w64\q
The q session opens with a banner like this.
KDB+ 4.0 2020.06.01 Copyright (C) 1993-2020 Kx Systems
m64/ 12()core 65536MB sjt mackenzie.local 127.0.0.1 EXPIRE…
q)
License files and 32-bit kdb+
32-bit kdb+ does not require a license file to run, but if it finds one at launch it will signal a license error if the license is not valid.
Try your first expression.
q)til 6
0 1 2 3 4 5
End the q session and return to the command shell.
q)\\
$
Step 5: Edit your profile¶
Defining q
as a command allows you to invoke kdb+ without specifying the path to it.
The q interpreter refers to environment variable QHOME
for the location of certain files.
Without this variable, it will guess based on the path to the interpreter.
Better to set the variable explicitly.
The QLIC
environment variable tells kdb+ where to find a license key file. Absent the variable, QHOME
is used.
- Open
~/.bash_profile
in a text editor, append the following line, and save the file. (Edit~/.bashrc
to define a q command for non-console processes.) export QHOME=~/q
export PATH=~/q/l64/:$PATH
- In the command shell, use the revised profile:
source .bash_profile
- Open
~/.zshrc
in a text editor, append the following lines, and save the file. export QHOME=~/q
export PATH=~/q/m64/:$PATH
- In the command shell, use the revised profile:
source ~/.zshrc
In the command shell issue the following commands:
setx QHOME "C:\q"
setx PATH "%PATH%;C:\q\w64"
(In the above, substitute 32
for 64
if you are installing 32-bit kdb+.)
Test the new command. Open a new command shell and type q
.
Last login: Sat Jun 20 12:42:49 on ttys004
❯ q
KDB+ 4.0 2020.06.01 Copyright (C) 1993-2020 Kx Systems
m64/ 12()core 65536MB sjt mackenzie.local 127.0.0.1 EXPIRE…
q)
Further customization¶
rlwrap for Linux and macOS¶
On Linux and macOS, the rlwrap
command allows the Up arrow to retrieve earlier expressions in the q session. This can be very useful and it is recommended you install it.
Run rlwrap -v
to check if it's currently installed. If not, install rlwrap
using your package manager. Common package managers are: apt
, dnf
and yum
for Linux, and Homebrew and MacPorts for macOS.
After installation, the q command can be changed to always run with rlwrap
:
alias q="rlwrap -r q"
This can be added to the end of the user's profile to take effect on every session.
Interactive development environments¶
If you are a solo student, we recommend learning q by running it from a command shell, as a REPL, writing scripts in a text editor. The examples on this site are produced that way; visual fidelity should help you as you learn.
Jupyter notebooks are an interactive publishing format. We are producing lessons in this form and the library is growing. The JupyterQ interface lets you run q code in notebooks.
Notebooks are not, however, an IDE, and are unsuitable for studying features such as event handlers.
For more advanced study, use either the bare q REPL, or download and install our interactive development environment, KX Developer.
Multiple versions¶
Multiple versions of kdb+ can be installed on a system by following this guide.
What’s next?¶
Learn the q programming language, look through the reference card, or see in the Database what you can do with kdb+.