bryanyang0528 / ksql-python

A python wrapper for the KSQL REST API.
MIT License
159 stars 67 forks source link

client.ksql('show tables') returns error 'not all arguments converted during string formatting' #72

Closed rayserrano2735 closed 4 years ago

rayserrano2735 commented 4 years ago

from ksql import KSQLAPI api_key = 'ZD74E3GRK4QXWO6W' api_secret = 'RByQinKf4ZYodiBLuCKybx92SSPrQwEwnA8DOaVfJEhAVf3LQ096yFteZkep4XKx' ksql_endpoint = 'https://pksqlc-42o7q.us-east-1.aws.confluent.cloud:443' client = KSQLAPI(ksql_endpoint, api_key=api_key, secret=api_secret) client.ksql('show tables')

This code returns:

not all arguments converted during string formatting

The offending code is in line 108 of api.py

base64string = base64.b64encode('{}:{}' % (self.api_key, self.secret))

Other calls to client return the same error, such as client.query('select userid from users')

rayserrano2735 commented 4 years ago

I modified the code this way:

if self.api_key and self.secret: key_secret = '{}:{}'.format(self.api_key, self.secret) base64string = base64.b64encode(key_secret.encode('utf-8')) headers["Authorization"] = "Basic {}" % base64string

This change eliminated the original error, but now we get an error a few lines below