I am totally new to q-language, but I need to use it in order to access a kdb server to get the data from.
I am using Python 3.8, under Windows10, with qPython installed.
I have trouble getting the query to the server.
from qpython import qconnection
import pandas as pd
tbl = 'q("h\"select from trade where date = 2007.02.28, sym = `XXXX\"")'
q = qconnection.QConnection(host=server, port=server_port, username=user, password=server_password, timeout=server_timeout)
q.open()
df = pd.DataFrame(q.sendSync('tbl'))
q.close()
On executing the script it returns an error at line 15:
qpython.qtype.QException: b'tbl'
So I have a trouble sending the correct expression to the server. I was able to pass the expression via terminal, using q (with PyQ) under Linux Debian 10, so the query is correct.
(The server details are skipped, as well as the bond name).
PyQ and qPython are being confused here. q.sendSync('tbl')
will get the variable tbl from the kdb server. This error: qpython.qtype.QException: b'tbl'
means tbl doesn't exist on the kdb server. I think what you wanted is the select statement to be sent to the kdb server:
from qpython import qconnection
import pandas as pd
q = qconnection.QConnection(host=server, port=server_port, username=user, password=server_password, timeout=server_timeout, pandas=True)
q.open()
df = q.sendSync('select from trade where date = 2007.02.28, sym = `XXXX')
q.close()
It might be worth while for you to spend sometime with q itself and get up to speed with some basics here: