Skip to content

PyKX Execution Classes

This page documents the base class for all interfaces between Python and the embedded q process.

pykx.Q

pykx.Q()
See Also
  • [pykx.EmbeddedQ][]
  • [pykx.QConnection][]

Abstract base class for all interfaces between Python and q.

_register

_register(name=None, path=None)

Switch to a named q context (read Q for Mortals Chapter 12) and load variable definitions into that context from a q/k script. Once the script is loaded this function switches back to the previous q context.

Parameters:

Name Type Description Default
name Optional[str]

Name to assign the context being loaded. If no argument is provided the assigned name of the context is set to the name of the file without filetype extension.

None
path Optional[Union[Path, str]]

Path to the script to load. If no argument is provided this function searches for a file matching the given name, loading it if found.

None

Returns:

Type Description
str

The attribute name for the newly loaded module.

pykx.EmbeddedQ

pykx.EmbeddedQ()

Bases: Q

Interface for using q within the current python process. Call this to execute q code.

__call__

__call__(query, *args, wait=None, debug=False, skip_debug=False, **kwargs)

Run q code in the q instance.

Parameters:

Name Type Description Default
query Union[str, bytes, wrappers.CharVector]

The code to run in the q instance.

required
*args Any

Arguments to the q query. Each argument is converted into a pykx.K object. This parameter supports up to 8 args (the maximum amount supported by q functions), providing more causesw an error.

()
wait Optional[bool]

A keyword to allow users to call any pykx.EmbeddedQ or pykx.QConnection instance the same way. All queries executed by this function are synchronous on the embedded q instance. Using a False argument for this parameter returns a q generic null (::).

None

Returns:

Type Description
wrappers.K

The value obtained by evaluating the query within the current process.

Raises:

Type Description
LicensedException

Attempted to execute q code outside of licensed mode.

TypeError

Too many arguments were provided - q queries cannot have more than 8 parameters.