KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums PyKX kx.q.sql(‘select * from trades’) command error

  • rocuinneagain

    Member
    June 19, 2023 at 12:00 am
    1. What version of PyKX as you using?
    2. 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 
    '))

     

     

  • yannlecun

    Member
    June 23, 2023 at 12:00 am

    Python 3.10.10 | packaged by conda-forge | (main, Mar 24 2023, 20:12:31) [Clang 14.0.6 ] on darwinType “help”, “copyright”, “credits” or “license” for more information.>>> import pykx>>> print(‘n’.join(pykx.q(‘.z.l 4’).py().decode().split()))insights.lib.embedqinsights.lib.pykxinsights.lib.sqlinsights.app.rtinsights.lib.qloginsights.lib.kurlinsights.lib.objstoreinsights.lib.bigqueryinsights.lib.restserver>>>

  • yannlecun

    Member
    June 23, 2023 at 12:00 am

    >>> 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’)Traceback (most recent call last):File “”, line 1, in File “/opt/anaconda3/envs/shift/lib/python3.11/site-packages/pykx/query.py”, line 528, in __call__return self._q(‘.s.sp’, k.CharVector(query), args)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File “/opt/anaconda3/envs/shift/lib/python3.11/site-packages/pykx/embedded_q.py”, line 142, in __call__return factory(result, False)^^^^^^^^^^^^^^^^^^^^^^File “pykx/_wrappers.pyx”, line 499, in pykx._wrappers._factoryFile “pykx/_wrappers.pyx”, line 492, in pykx._wrappers.factorypykx.exceptions.QError: .s.sp

  • rocuinneagain

    Member
    June 23, 2023 at 12:00 am

    To 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

  • yannlecun

    Member
    June 23, 2023 at 12:00 am
    >>> 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')
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/opt/anaconda3/envs/shift/lib/python3.11/site-packages/pykx/query.py", line 528, in __call__
    return self._q('.s.sp', k.CharVector(query), args)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/opt/anaconda3/envs/shift/lib/python3.11/site-packages/pykx/embedded_q.py", line 142, in __call__
    return factory(result, False)
    ^^^^^^^^^^^^^^^^^^^^^^
    File "pykx/_wrappers.pyx", line 499, in pykx._wrappers._factory
    File "pykx/_wrappers.pyx", line 492, in pykx._wrappers.factory
    pykx.exceptions.QError: .s.sp
  • rocuinneagain

    Member
    June 23, 2023 at 12:00 am

    To 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

     

  • yannlecun

    Member
    June 23, 2023 at 12:00 am

    Python 3.10.10 | packaged by conda-forge | (main, Mar 24 2023, 20:12:31) [Clang 14.0.6 ] on darwin
    Type “help”, “copyright”, “credits” or “license” for more information.
    >>> import pykx
    >>> print(‘n’.join(pykx.q(‘.z.l 4’).py().decode().split()))
    insights.lib.embedq
    insights.lib.pykx
    insights.lib.sql
    insights.app.rt
    insights.lib.qlog
    insights.lib.kurl
    insights.lib.objstore
    insights.lib.bigquery
    insights.lib.restserver
    >>>

  • rocuinneagain

    Member
    June 27, 2023 at 12:00 am

    Can 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)

  • yannlecun

    Member
    June 27, 2023 at 12:00 am

    missing ‘_update_marker’

  • yannlecun

    Member
    June 27, 2023 at 12:00 am

    >>> import pykx>>> pykx.q(‘l s.k_’)pykx.Identity(pykx.q(‘::’))>>> import os>>> os.environ[“QHOME”]’/opt/anaconda3/envs/shift/lib/python3.11/site-packages/pykx/lib’>>> os.listdir(os.environ[“QHOME”])[‘objstor.q_’, ‘q.k’, ‘rest.q_’, ‘kurl.sidecar.q_’, ‘bq.q_’, ‘m64’, ‘m64arm’, ‘kxic.k’, ‘read.q’, ‘csvutil.q’, ‘qlog.q_’, ‘l64arm’, ‘kurl.q_’, ‘w64’, ‘s.k_’, ‘write.q’, ‘p.q’, ‘l64’]

  • yannlecun

    Member
    June 27, 2023 at 12:00 am
    >>> import pykx
    >>> pykx.q('l s.k_')
    pykx.Identity(pykx.q('::'))
    >>> import os
    >>> os.environ["QHOME"]
    '/opt/anaconda3/envs/shift/lib/python3.11/site-packages/pykx/lib'
    >>> os.listdir(os.environ["QHOME"])
    ['objstor.q_', 'q.k', 'rest.q_', 'kurl.sidecar.q_', 'bq.q_', 'm64', 'm64arm', 'kxic.k', 'read.q', 'csvutil.q', 'qlog.q_', 'l64arm', 'kurl.q_', 'w64', 's.k_', 'write.q', 'p.q', 'l64']
  • rocuinneagain

    Member
    June 27, 2023 at 12:00 am

    Can 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)

  • rocuinneagain

    Member
    June 28, 2023 at 12:00 am

    No it only needs to be done once. Normally importing PyKX should run it automatically but for some reason your install does not do this.

  • yannlecun

    Member
    June 28, 2023 at 12:00 am

    Thanks for your help.

  • rocuinneagain

    Member
    June 28, 2023 at 12:00 am

    As this ran without error you should now be able to use your query: >>> pykx.q(‘l s.k_’) pykx.Identity(pykx.q(‘::’)) Should now run: kx.q.sql(‘select * from trades’)

Page 1 of 2

Log in to reply.