Search code examples
python-3.6kdb

query kdb using qpython and python3.6


I'm using qpython to communicate with my kdb(tickdb) server. I have this simple script


q = qconnection.QConnection(host = 'host', port = 789)
q.open()
print(q)
print('IPC version: %s. Is connected: %s' % (q.protocol_version, q.is_connected()))
data = q('{`int$ til x}', 10)

which ends up with this exception qpython.qtype.QException: b'not an api call'


Solution

  • QException is a q error rather than python or qPython. As Sean has suggested it seems like you are not connecting to a vanilla kdb setup and there must be logic in the q process to block free-form user queries.

    I can force the error by updating the sync message handler .z.pg

    / basic example if a symbol isn't received by the q process will return an error from the q process
    q).z.pg:{if[not -11h~type x;'"not an api call"];value x}
    
    python test2.py
    
    :localhost:789
    IPC version: 3. Is connected: True
    Traceback (most recent call last):
    ....................................
        raise QException(self._read_symbol())
    qpython.qtype.QException: b'not an api call'