AttributeError: объект 'bool' не имеет атрибута 'encode', используя Apache Cassandra и Python - PullRequest
0 голосов
/ 02 мая 2020

Я использую python для вставки кадра данных в apache cassandra, но возвращается ошибка AttributeError: объект 'bool' не имеет атрибута 'encode'

cluster = Cluster(['127.0.0.1'])
session = cluster.connect()

def acessa_banco(palavra):
       session.execute("""CREATE KEYSPACE IF NOT EXISTS %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor' :'1' }""" % palavra)
       session.set_keyspace(palavra)
       session.execute("""
              create table if not exists stg_pesquisa_twitter(
                      usuario           text
                     ,localizacao       text
                     ,total_amigos      int 
                     ,total_seguidores  int 
                     ,total_listas      int         
                     ,total_likes       int          
                     ,status_verificado textfi‹
                     ,total_status      int  
                     ,total_retweet     int  
                     ,tweet             text
                     ,PRIMARY KEY(usuario)       
              ) WITH comment='Informacao dos twitter mais pesquisados';
       """
       )

       # insert da tabela 
       query = "insert into stg_pesquisa_twitter (usuario, localizacao, total_amigos, total_seguidores, total_listas, total_likes, status_verificado, total_status, total_retweet, tweet) \
                values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"

   prepared = session.prepare(query)
   for index, row in txt.iterrows():
          session.execute(prepared
                         ,(row['usuario']
                         , row['localizacao']
                         , row['total_amigos']
                         , row['total_seguidores']
                         , row['total_listas']
                         , row['total_likes']
                         , row['status_verificado']
                         , row['total_status']
                         , row['total_retweet']
                         , row['tweet'])
                         ) 

enter image description here

...