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

  • yannlecun

    Member
    June 28, 2023 at 12:00 am

    >>> 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 >>> pykx.q(‘l s.k_’)pykx.Identity(pykx.q(‘::’))>>> kx.q.sql(‘select * from trades’)pykx.Table(pykx.q(‘sym mcap ex——————-ibm 2000 nasdaqmsft 4000 nasdaqapple 9000 DAXsamsung 6000 Dow’)) Do I need to add “pykx.q(‘l s.k_’)” command before every kx.q.sql query?

  • 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')
  • yannlecun

    Member
    June 28, 2023 at 12:00 am
    >>> 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
    
    >>> pykx.q('l s.k_')
    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
    '))
    
    
    

    Do I need to add “pykx.q(‘l s.k_’)” command before every kx.q.sql query?

  • 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.

Page 2 of 2

Log in to reply.