3

I want to execute a KDB function within a Python Script. The KDB function is contained in a separate Q file though. So how can I read in this Q file and then query a function from within that Q file in Python?

Riley Hun
  • 2,541
  • 5
  • 31
  • 77

2 Answers2

5

You can use PyQ to call q into Python; a quick start guide is linked here . You can follow the instructions for installation and prompting q according to this link, then load in your script via the method shown in the example below.

Note: You should use the executable pyq rather than python to start.

$ pyq
>>> from pyq import q
>>> q()
q) \l /path/to/script.q
q) \
>>> x = q.f(arg1, arg2)
>>> x.show()

Hope that helps!

Jemma Borland
  • 390
  • 1
  • 7
R. Laidler
  • 649
  • 3
  • 5
0

Depending on what exactly you are trying to accomplish, qPython might be an alternative... It allows you to connect/subscribe to a kdb server from within a python script, run q code, queries, etc...

https://pypi.org/project/qPython/

SanMu
  • 645
  • 1
  • 6
  • 19