rocuinneagain
Forum Replies Created
-
rocuinneagain
MemberJune 27, 2023 at 12:00 am in reply to: kx.q.sql(‘select * from trades’) command errorCan you run:
>>> pykx.q('l s.k_')
If that still fails check
>>> import os >>> os.environ["QHOME"] '/home/user/folder/venv/lib/python3.10/site-packages/pykx/lib' >>> os.listdir(os.environ["QHOME"]) ['write.q', 'm64arm', 'p.q', 'l64arm', 'l64', 'kxic.k', '_update_marker', 'bq.q_', 'csvutil.q', 'kurl.q_', 'q.k', 's.k_', 'w64', 'qlog.q_', 'm64', 'objstor.q_', 'read.q', 'rest.q_', 'kurl.sidecar.q_']
PyKX 1.6.0 includes a utility for inspecting these common areas
pykx.util.debug_environment(detailed=True)
-
I have tested and 1.6.0 will allow the import to continue after this error.
This runs for me:
from prefect import flow from prefect.deployments import Deployment import os os.environ["QARGS"] = "--unlicensed" import pykx as kx def setup(): print("testing pykx") masterConn = kx.SyncQConnection( host='localhost', port=5000, timeout=3.0 ) user = masterConn('.z.u') print('User = ' + user.py()) port = masterConn('5000') print('Port = ' + str(port.py())) masterConn.close() global conn conn = kx.SyncQConnection( host='localhost', port=port.py()) user = conn('.z.u') print('User = ' + user.py()) @flow() def test_pykx(): setup() logger = get_run_logger() logger.info("Initializing initial arguments") dailyDates = conn('dailyDates:(.z.d-7)+til 7') logFile = conn('inLogFile:`') def deploy(): deployment = Deployment.build_from_flow( flow=test_pykx, name="prefect-example-deployment" ) deployment.apply() if __name__ == "__main__": deploy()
If you want to run in licensed mode you need to move the import of pykx to avoid a
nosocket
errorfrom prefect import flow from prefect.deployments import Deployment def setup(): import pykx as kx print("testing pykx") masterConn = kx.SyncQConnection( host='localhost', port=5000, timeout=3.0 ) user = masterConn('.z.u') print('User = ' + user.py()) port = masterConn('5000') print('Port = ' + str(port.py())) masterConn.close() global conn conn = kx.SyncQConnection( host='localhost', port=port.py()) user = conn('.z.u') print('User = ' + user.py()) @flow() def test_pykx(): setup() logger = get_run_logger() logger.info("Initializing initial arguments") dailyDates = conn('dailyDates:(.z.d-7)+til 7') logFile = conn('inLogFile:`') def deploy(): deployment = Deployment.build_from_flow( flow=test_pykx, name="prefect-example-deployment" ) deployment.apply() if __name__ == "__main__": deploy()
-
https://code.kx.com/q/ref/maps/#each
'
operates the same aseach
in these cases(first'') dict a| 1 `a b| 2 `b c| 3 `c {first each x} each dict a| 1 `a b| 2 `b c| 3 `c (first')dict a| 1 b| 2 c| 3 first each dict a| 1 b| 2 c| 3
-
rocuinneagain
MemberJune 23, 2023 at 12:00 am in reply to: .Q.par Doesn’t Provide the Correct Result in the Segmented db.Yes there is a warning on: https://code.kx.com/q/database/segment/#considerations
“Partition data correctly: data for a particular date must reside in the partition for that date.“
-
rocuinneagain
MemberJune 23, 2023 at 12:00 am in reply to: kx.q.sql(‘select * from trades’) command errorTo use sql library you will need the correct flag in your license:
>>> print('n'.join(pykx.q('.z.l 4').py().decode().split())) insights.lib.embedq insights.lib.pykx insights.lib.sql ##<<------ Do you see this? insights.lib.qlog insights.lib.kurl insights.lib.objstore insights.lib.bigquery insights.lib.restserver
-
rocuinneagain
MemberJune 23, 2023 at 12:00 am in reply to: kx.q.sql(‘select * from trades’) command errorTo use sql library you will need the correct flag in your license: >>> print(‘n’.join(pykx.q(‘.z.l 4’).py().decode().split())) insights.lib.embedq insights.lib.pykx insights.lib.sql ##<<—— Do you see this? insights.lib.qlog insights.lib.kurl insights.lib.objstore insights.lib.bigquery insights.lib.restserver
-
3.11 support has just been added – we’ll get those docs updated. Thanks!
https://code.kx.com/pykx/1.6/changelog.html#pykx-160
- Added support for Python
3.11
.- Support for pyarrow in this python version is currently in Beta.
- Added support for Python
-
rocuinneagain
MemberJune 19, 2023 at 12:00 am in reply to: kx.q.sql(‘select * from trades’) command error- What version of PyKX as you using?
- Can you run this example?
>>> import pykx as kx >>> kx.__version__ '1.6.0' >>> kx.q('trades: ([]sym:`ibm`msft`apple`samsung;mcap:2000 4000 9000 6000;ex:`nasdaq`nasdaq`DAX`Dow)') pykx.Identity(pykx.q('::')) >>> kx.q.sql('select * from trades') pykx.Table(pykx.q(' sym mcap ex ------------------- ibm 2000 nasdaq msft 4000 nasdaq apple 9000 DAX samsung 6000 Dow '))
- Creating q code block with syntax highlighting in a message
- Adding inline code to your questions & messages
-
rocuinneagain
MemberJune 9, 2023 at 12:00 am in reply to: Decimal type or representing very big numbers -
-
rocuinneagain
MemberJune 7, 2023 at 12:00 am in reply to: Apply a list of parameters to a list of inputq)b@'(0;2;1)
1 76 12
-
Link to your original post for reference:
You can test yourself and compare time and memory usage:
- https://code.kx.com/q/basics/syscmds/#ts-time-and-space
- https://code.kx.com/q/wp/columnar-database/
- https://code.kx.com/q/ref/set-attribute/
//Try and time the queries to compare \ts select last price by hour:60 xbar time.minute, sym from trade \ts select last price by sym,hour:60 xbar time.minute from trade //If they run very fast you can run them N number of times to get more accurate result //Running 100 times here \ts:100 select last price by hour:60 xbar time.minute, sym from trade \ts:100 select last price by sym,hour:60 xbar time.minute from trade //Attributes are useful in kdb+ //Apply grouped on sym and test update `g#sym from `trade \ts:100 select last price by hour:60 xbar time.minute, sym from trade \ts:100 select last price by sym,hour:60 xbar time.minute from trade //Removed grouped and test again update `#sym from `trade \ts:100 select last price by hour:60 xbar time.minute, sym from trade \ts:100 select last price by sym,hour:60 xbar time.minute from trade
-
rocuinneagain
MemberJune 1, 2023 at 12:00 am in reply to: pip install kxi – ERROR: No matching distribution found for kxiPass your credentials and the URL to the KX repository:
pip install --extra-index-url=https://$KX_PYPI_USER:$KX_PYPI_PASS@nexus.dl.kx.com/repository/kxi/simple/ kxi
The documentation will be updated to correct this.