lordingtar
lordingtar

Reputation: 1052

TypeError: not all arguments converted during string formatting in CQL

I'm trying to insert a variable string into a Cassandra table using the following code:

b64_enc = "R21haWw="
class SimpleClient:
    session = None

    def create_schema(self):
        self.session.execute("""CREATE KEYSPACE raas WITH replication = {'class':'SimpleStrategy', 'replication_factor':3};""")
        self.session.execute("""
            CREATE TABLE raas.result (
                userb64enc text PRIMARY KEY,
                statusflag int,
                statusstr text
            );
        """)
        log.info('Simplex keyspace and schema created.')

    def load_data(self):

        self.session.execute("""INSERT INTO raas.result (userb64enc, statusflag, statusstr) VALUES(%s,0,'Success');""",  (b64_enc))
        log.info('Data loaded.')

But I get a

TypeError: not all arguments converted during string formatting

message. I've also tried using ? in place of the %s, but I get the same error. Any idea on what the cause of this error is?

Upvotes: 2

Views: 3064

Answers (1)

lordingtar
lordingtar

Reputation: 1052

I answered my own question - the %s has to be in quotes because it is of type text.

Upvotes: 4

Related Questions