The lowest-level official API for accessing Cassandra is that of the Thrift interface. This is primarily intended for client library developers; application developers are strongly advised to use a higher-level client as described in ClientOptions.
Should you wish to use the Thrift API, see API for what data structures and method calls are available.
The purpose of using Thrift in Cassandra is allow portable (across programming languages) access to the database. Thrift accomplishes this by generated source code for the programming language in question based on a Thrift IDL file describing the service (see here).
Let's see how we can use a generated python client to access Cassandra.
- cd cassandra/interface
- thrift -gen py cassandra.thrift
- cd gen-py/cassandra
Run the script without arguments to get usage information:
Usage: ./Cassandra-remote [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]
Some examples of setting and getting values:
$ ./Cassandra-remote -h cass-1:9160 insert Keyspace1 eevans "ColumnPath('Standard1', column='fruit')" apple 1 ConsistencyLevel.QUORUM
None
$ ./Cassandra-remote -h cass-1:9160 get Keyspace1 eevans "ColumnPath('Standard1', column='fruit')" ConsistencyLevel.QUORUM
ColumnOrSuperColumn(column=Column(timestamp=1, name='fruit', value='apple'), super_column=None)