clients.cassandra

Base functionality for accessing/modifying data in Cassandra.

class sprockets.clients.cassandra.CassandraConnection(ioloop=None)[source]

Maintain a connection to a Cassandra cluster.

The Sprockets Cassandra client handles provides the glue needed to join the Tornado async I/O module with the native python async I/O used in the Cassandra driver. The constructor of the function will grab the current handle to the underlying Tornado I/O loop so that a Tornado future result can be returned to the host application.

Configuration parameters for the module are obtained from environment variables. Currently, the only variable is CASSANDRA_URI, which takes the format “cassandra://hostname”. If not located, the hostname defaults to localhost.

Note

The hostname in the CASSANDRA_URI will be resolved to a list of IP addresses that will be passed to the Cassandra driver as the contact points.

execute(query, *args, **kwargs)[source]

Asynchronously execute the specified CQL query.

The execute command also takes optional parameters and trace keyword arguments. See cassandra-python documentation for definition of those parameters.

set_keyspace(keyspace)[source]

Set the keyspace used by the connection.

shutdown()[source]

Shutdown the connection to the Cassandra cluster.