Skip to content

Q & Embedded Q

pykx.Q

pykx.Q()
See Also

Abstract base class for all interfaces between Python and q.

_register

_register(name=None, path=None)

Obtain the definitions from a q/k script.

Parameters:

Name Type Description Default
name Optional[str]

Name of the context to be loaded. If path is not provided, a file whose name matches will be searched for, and loaded if found. If path is provided, name will be used as the name of the context that the script at path is executed in.

None
path Optional[Union[Path, str]]

Path to the script to load. If name is not provided, it will default to the filename sans extension.

None

Returns:

Type Description
str

The attribute name for the newly loaded module.

pykx.EmbeddedQ

pykx.EmbeddedQ()

Bases: Q

Interface for q within the current process; can be called to execute q code.

__call__

__call__(query, *args, wait=None, sync=None)

Run 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 will be converted into a pykx.K object. Up to 8 arguments can be provided, as that is the maximum supported by q.

()
wait Optional[bool]

Keyword argument provided solely for conformity with pykx.QConnection. All queries against the embedded q instance are synchronous regardless of what this parameter is set to. Setting this keyword argument to False results in q generic null (::) being returned, so as to conform with pykx.QConnection. This conformity enables one to call any pykx.Q instance the same way regardless of whether it is a pykx.EmbeddedQ or pykx.QConnection instance. For cases where the query executing asynchronously (and returning after it has been issued, rather than after is is done executing) is actually important, one can discriminate between pykx.Q instances using isinstance as normal.

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.