'Inserting values with python wrapper for KSQLDB

im trying to enrich a stream with more data. F.E: I have a stream and need to add a calculated field based on the data. After getting the new data for the new Column i want to insert the row with the enriched field into a new Stream. When im doing it with the KSQLCLI, it works. When i use the python Wrapper Client it ain't inserting the values. Any help is appreciated Code:

client.ksql("""CREATE STREAM STREAM_COMPASS_UPDATE (ROWKEY BIGINT KEY, ID BIGINT, SCREENNAME STRING, TEXT STRING, LOCATION STRING, LANG STRING, LAT DOUBLE, LONG DOUBLE, PLACE_NAME STRING, PLACE_STREET STRING, PLACE_FULLNAME STRING, RETWEET BOOLEAN, COMPASS_DIRECTION STRING) WITH (KAFKA_TOPIC='TWEETS_GER_USERLOCATION_PLACE_COMPASS', PARTITIONS`=2, REPLICAS=1, VALUE_FORMAT='Avro');""")

Insert the data with new column(compass_direction):

q= """INSERT INTO STREAM_COMPASS_UPDATE (text, location, ID, SCREENNAME, LANG, LAT, LONG, PLACE_NAME, PLACE_STREET, PLACE_FULLNAME, RETWEET, COMPASS_DIRECTION) VALUES ("""+ "'" + text + "','"+ i.location.replace(',',';').encode('utf-8', 'replace').decode() + "',"+ str(last_id) + ",'" + str(i.user) + "','" + str(i.lang) + "'," + str(i.lat) + "," + str(i.long) + "," + str(i.place_name) + ","+  str(i.place_street) +","+ str(i.place_fullname) + "," + str(i.retweet) + "," + "'" + str(i.compass_direction) + "');""" 

client.query(q)

When i print out the query and copy paste it into the KSQLDB CLI the row gets inserted. When i do it with the python wrapper no data gets inserted into the stream. What am i missing or doing wrong?

pythonwrapper: https://github.com/bryanyang0528/ksql-python



Solution 1:[1]

Try client.ksql(q) instead of client.query(q)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ritu