Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Python Thrift driver for Apache Cassandra
Python Other
Failed to load latest commit information.
debian [debian] Update d/rules and switch to non-native package
doc Update changelog, bump version to 1.11.1
tests Stubs and tests minor cleanup
.travis.yml Wait for and verify C* startup in Travis
CHANGES Update changelog, bump version to 1.11.1
LICENSE add cassandra python lib, README, and LICENSE
README.mkd Fix readme, doc formatting Upgrade to latest
pycassaShell Added missing colon for for loop in pycassaShell Merge commit '2612990e0581c7fb1a3c1932fd4df9c6a246f928' set post-release version



Build Status

pycassa is a Thrift-based python client library for Apache Cassandra

pycassa does not support CQL or Cassandra's native protocol, which are a replacement for the Thrift interface that pycassa is based on. If you are starting a new project, it is highly recommended that you use the newer DataStax python driver instead of pycassa.

pycassa is open source under the MIT license.


Documentation can be found here:

It includes installation instructions, a tutorial, API documentation, and a change log.

Getting Help


Mailing List:


If pip is available, you can install the lastest pycassa release with:

pip install pycassa

If you want to install from a source checkout, make sure you have Thrift installed, and run as a superuser:

pip install thrift
python install

Basic Usage

To get a connection pool, pass a Keyspace and an optional list of servers:

>>> import pycassa
>>> pool = pycassa.ConnectionPool('Keyspace1') # Defaults to connecting to the server at 'localhost:9160'
>>> # or, we can specify our servers:
>>> pool = pycassa.ConnectionPool('Keyspace1', server_list=[''])

To use the standard interface, create a ColumnFamily instance.

>>> pool = pycassa.ConnectionPool('Keyspace1')
>>> cf = pycassa.ColumnFamily(pool, 'Standard1')
>>> cf.insert('foo', {'column1': 'val1'})
>>> cf.get('foo')
{'column1': 'val1'}

insert() will also update existing columns:

>>> cf.insert('foo', {'column1': 'val2'})
>>> cf.get('foo')
{'column1': 'val2'}

You may insert multiple columns at once:

>>> cf.insert('bar', {'column1': 'val3', 'column2': 'val4'})
>>> cf.multiget(['foo', 'bar'])
{'foo': {'column1': 'val2'}, 'bar': {'column1': 'val3', 'column2': 'val4'}}
>>> cf.get_count('bar')

get_range() returns an iterable. You can use list() to convert it to a list:

>>> list(cf.get_range())
[('bar', {'column1': 'val3', 'column2': 'val4'}), ('foo', {'column1': 'val2'})]
>>> list(cf.get_range(row_count=1))
[('bar', {'column1': 'val3', 'column2': 'val4'})]

You can remove entire keys or just a certain column:

>>> cf.remove('bar', columns=['column1'])
>>> cf.get('bar')
{'column2': 'val4'}
>>> cf.remove('bar')
>>> cf.get('bar')
Traceback (most recent call last):
pycassa.NotFoundException: NotFoundException()

See the tutorial for more details.

Something went wrong with that request. Please try again.