I try to access my local cassandra database via python. Therefore I
installed db-api 2.0 and thrift for accessing the database. Opening
and closing a connection works fine. But a simply query is not
working:

The script looks like this:

    c = conn.cursor()
    c.execute("""select * from users;""")
    data = c.fetchall()
    print "Query: select * from users; returned the following result:"
    print str(data)


The table users looks like this:
qlsh:demodb> select * from users;

 user_name | birth_year | gender | password | session_token | state
-----------+------------+--------+----------+---------------+-------
    jsmith |       null |   null |   secret |          null |  null



But when I try to execute it I get the following error:
Open connection to localhost:9160 on keyspace demodb
Traceback (most recent call last):
  File 
"/Users/Tom/Freelancing/Company/Python/ApacheCassandra/src/CassandraDemo.py",
line 56, in <module>
    perfromSimpleCQLQuery()
  File 
"/Users/Tom/Freelancing/Company/Python/ApacheCassandra/src/CassandraDemo.py",
line 46, in perfromSimpleCQLQuery
    c.execute("""select * from users;""")
  File "/Library/Python/2.7/site-packages/cql/cursor.py", line 81, in execute
    return self.process_execution_results(response, decoder=decoder)
  File "/Library/Python/2.7/site-packages/cql/thrifteries.py", line
116, in process_execution_results
    self.get_metadata_info(self.result[0])
  File "/Library/Python/2.7/site-packages/cql/cursor.py", line 97, in
get_metadata_info
    name, nbytes, vtype, ctype = self.get_column_metadata(colid)
  File "/Library/Python/2.7/site-packages/cql/cursor.py", line 104, in
get_column_metadata
    return self.decoder.decode_metadata_and_type(column_id)
  File "/Library/Python/2.7/site-packages/cql/decoders.py", line 45,
in decode_metadata_and_type
    name = self.name_decode_error(e, namebytes,
comptype.cql_parameterized_type())
  File "/Library/Python/2.7/site-packages/cql/decoders.py", line 29,
in name_decode_error
    % (namebytes, expectedtype, err))
cql.apivalues.ProgrammingError: column name '\x00\x00\x00' can't be
deserialized as 'org.apache.cassandra.db.marshal.CompositeType':
global name 'self' is not defined

I'm not shure if this is the right place to ask for: But am I doing
here something wrong?

Reply via email to