Skip to content

Command Line Interface

The Command Line Interface (CLI) for interacting with Packages is fully integrated with the kxi CLI as outlined here. The package command within the kxi CLI allows you to create, package and manage packages locally and within a kdb Insights Enterprise installation. Installation of the kxi CLI can be achieved following the instructions outlined here.

The following is the list of available commands:

$ kxi package --help 
Usage: kxi package [OPTIONS] COMMAND [ARGS]...

  KX Package Import/Export CLI.

  --version                     Version information.
  --artifact-store DIRECTORY    Directory in which to store packed
                                artifacts;[default] $KX_ARTIFACT_PATH.
  --pkg-lib DIRECTORY           Directory in which packages will be
                                installed;[default] $KX_PACKAGE_PATH.
  --deployment-store DIRECTORY  Directory in which deployment data is
                                stored;[default] $KX_DEPLOYMENT_PATH.
  --debug                       Enable stacktrace print statements for easier
  --help                        Show this message and exit.


  When pulling/pushing to a KX Insights package repository, use these commands:

    pull           Download an artifact from the running insights package
                   manager service to...
    push           Publish an artifact to the running insights package manager
    remote-list    List all installed packages or artifacts on the running
                   insights package...
    remote-remove  Remove packages or artifacts from the running insights
                   package manager...

  For local development, use these commands:

    init       Creates a bare package at the specified target path.
    install    Install a package given a requirement or path.
    list       List all installed packages or artifacts.
    lock       Lock the q files within a source directory.
    packit     Create a package artifact given a source code directory.
    uninstall  Uninstall specified locally installed packages and artifacts.
    unpack     Unpack an artifact to a specified location.
    validate   Validate the contents of a source directory to ensure it is a
               valid package.

  For managing deployments & runtime of packages on KX Insights, use these commands:

    deploy    Deploy a package to an insights instance
    teardown  Teardown a deployed packaged running on an insights instance

  For managing components added to package, use these commands:

    add      Add an entity to the specified package.
    copy     Copy an entity from the specified package.
    refresh  Refresh an entity of the specified package.
    rm       Remove an entity from the specified package.

Interactions with packages can be local or remote. Packages and their associated artifacts are stored in a location (either locally or on an kdb Insights Enterprise installation) specified by user-defined paths, KX_PACKAGE_PATH and KX_ARTIFACT_PATH respectively. This section does not cover interactions with an Insights installation. For details, follow the guide here.


This quickstart provides you with a step-by-step guide to:

  1. Initialize a package locally.
  2. Update this package to include user-defined code.
  3. Package this entity to generate an artifact.
  4. Install this package locally, allowing it to be loaded and used locally.

The quickstart assumes that you have:

  • Installed the kxicli package (version >= 1.0.0) following the instructions here

Generate a simple package locally

  1. Create and define custom artifact and package paths.

    $ mkdir -p /tmp/test-packages
    $ mkdir -p /tmp/test-artifacts
    $ export KX_PACKAGE_PATH=/tmp/test-packages
    $ export KX_ARTIFACT_PATH=/tmp/test-artifacts
    Default values

    The default values for these paths are as follows

    $ echo $KX_PACKAGE_PATH
    $ echo $KX_ARTIFACT_PATH
  2. Initialize a package with minimal content. Run this command from a clean working directory, taking into account the following warning.


    Both the KX_PACKAGE_PATH and KX_ARTIFACT_PATH locations are used as load and storage locations for installed local packages, the initialization of packages in either location can result in unexpected behavior and should be avoided.

    $ kxi package init qpackage
    Creating package at location: qpackage
    Writing qpackage/manifest.json
    $ tree qpackage
    ├── init.q
    └── manifest.json
  3. Create a file src/sp.q within the qpackage folder created by the initialization of the package outlined above. This file contains a User-Defined Function (UDF) and variable. Documentation outlining the structure for this UDF is provided here.

    $ cat src/sp.q
    // @udf.tag("sp")
    // @udf.category("map"){[table;params]
       select from table where x<10
  4. You can now update the init.q file to load the src/sp.q file.

    $ cat init.q
    // Load the src/sp.q file relative to package root
  5. Package the artifact defining the version of the package on the command line. Run this command from the original directory where you initialized the package qpackage.

    $ kxi package packit qpackage --version 1.0.0 --tag
    Creating package from qpackage
    Package created: /tmp/artifacts/qpackage-1.0.0.kxi
  6. Install the package locally such that it can be loaded into processes using Python/q locally.

    $ kxi package install qpackage-1.0.0.kxi
        "qpackage": [
                "version": "1.0.0",
                "_status": "InstallationStatus.SUCCESS"
  7. List the current artifacts available locally.

    $ kxi package list --artifacts
        "qpackage": {
            "1.0.0": {}

Once you have generated your package locally, you can follow the guide here to learn more about uploading and interacting with packages within kdb Insights Enterprise.