Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response of client.query RuntimeError #106

Open
marcodungeon opened this issue May 9, 2022 · 0 comments
Open

Response of client.query RuntimeError #106

marcodungeon opened this issue May 9, 2022 · 0 comments
Labels

Comments

@marcodungeon
Copy link

I'm trying to read from ksql in python with this script:

from ksql import KSQLAPI

client = KSQLAPI('http://0.0.0.0:8088',)
columns = ['id INT','name VARCHAR']
client.create_stream(table_name='students', columns_type= columns, topic='students')
query = client.query("SELECT name FROM students WHERE id = 1 ")
for student in query:
    print(student)

I was expecting a sequence of objects, as the documentation explains, instead it returns me a string representing pieces of an array of objects, with headers and at the end, a "RuntimeError: generator raised StopIteration" (each row is generated separately):

[{"header":{"queryId":"transient_STUDENTS_5788262560238090205","schema":"`NAME` STRING"}},

{"row":{"columns":["Alex"]}},

]

---------------------------------------------------------------------------
StopIteration                             Traceback (most recent call last)
[...]
The above exception was the direct cause of the following exception:
RuntimeError                              Traceback (most recent call last)
[...]
RuntimeError: generator raised StopIteration

This way I have to handle the exception or I have to break the loop when I find the ']' character. Also, I need to clean up each string because it is not a valid JSON (due to the final comma and new line), before deserializing it into a Python object with json.loads(str).

@KenCox94 KenCox94 added the bug label Jul 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants