<commit_before>pycassa
=======

pycassa is a python client library for Apache Cassandra with the following features:

1. Auto-failover for normal or thread-local connections
2. Connection pooling
3. A batch interface
4. A method to map an existing class to a Cassandra column family

Documentation
-------------

Documentation can be found here:

[http://pycassa.github.com/pycassa/](http://pycassa.github.com/pycassa/)

It includes [installation instructions](http://pycassa.github.com/pycassa/installation.html),
a [tutorial](http://pycassa.github.com/pycassa/tutorial.html),
[API documentation](http://pycassa.github.com/pycassa/api/index.html),
and a [change log](http://pycassa.github.com/pycassa/changelog.html).

Getting Help
------------

IRC:

* Use channel #cassandra on irc.freenode.net. If you don't have an IRC client,
  you can use [freenode's web based client](http://webchat.freenode.net/?channels=#cassandra).

Mailing List:

* User list: [http://groups.google.com/group/pycassa-discuss](http://groups.google.com/group/pycassa-discuss)
* Developer list: [http://groups.google.com/group/pycassa-devel](http://groups.google.com/group/pycassa-devel)

Installation
------------

If easy_install is available, you can use:

    easy_install pycassa

The simplest way to install manually is to copy the pycassa directories to
your program.  If you want to install, make sure you have thrift installed,
and run setup.py as a superuser.

    easy_install thrift05
    python setup.py install

Connecting
----------

All functions are documented with docstrings.  To read usage documentation,
you can use help:

    >>> import pycassa
    >>> help(pycassa.ColumnFamily.get)

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

    >>> pool = pycassa.connect('Keyspace1') # Defaults to connecting to the server at 'localhost:9160'
    >>> pool = pycassa.connect('Keyspace1', ['192.168.2.10:9160'])

See the [tutorial](http://pycassa.github.com/pycassa/tutorial.html#connecting-to-cassandra) for more details.

Basic Usage
-----------

To use the standard interface, create a ColumnFamily instance.

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

insert() also acts to update values:

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

You may insert multiple columns at once:

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

get_range() returns an iterable. Call it with list() to convert it to a list.

    >>> list(cf.get_range())
    [('bar', {'column1': 'val3', 'column2': 'val4'}), ('foo', {'column1': 'val2'})]<commit_msg>README cleanup of features and connect() usage<commit_after>pycassa
=======

pycassa is a python client library for [Apache Cassandra](http://cassandra.apache.org)
with the following features:

* Automatic failover and operation retries
* Connection pooling
* Multithreading support
* A batch interface
* A class for mapping classes to Cassandra column families

The latest release is compatible with Cassandra 0.7 and 0.8.

Documentation
-------------

Documentation can be found here:

[http://pycassa.github.com/pycassa/](http://pycassa.github.com/pycassa/)

It includes [installation instructions](http://pycassa.github.com/pycassa/installation.html),
a [tutorial](http://pycassa.github.com/pycassa/tutorial.html),
[API documentation](http://pycassa.github.com/pycassa/api/index.html),
and a [change log](http://pycassa.github.com/pycassa/changelog.html).

Getting Help
------------

IRC:

* Use channel #cassandra on irc.freenode.net. If you don't have an IRC client,
  you can use [freenode's web based client](http://webchat.freenode.net/?channels=#cassandra).

Mailing List:

* User list: [http://groups.google.com/group/pycassa-discuss](http://groups.google.com/group/pycassa-discuss)
* Developer list: [http://groups.google.com/group/pycassa-devel](http://groups.google.com/group/pycassa-devel)

Installation
------------

If easy_install is available, you can use:

    easy_install pycassa

The simplest way to install manually is to copy the pycassa directories to
your program.  If you want to install, make sure you have thrift installed,
and run setup.py as a superuser.

    easy_install thrift
    python setup.py install

Connecting
----------

All functions are documented with docstrings.  To read usage documentation,
you can use help:

    >>> import pycassa
    >>> help(pycassa.ColumnFamily.get)

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

    >>> pool = pycassa.ConnectionPool('Keyspace1') # Defaults to connecting to the server at 'localhost:9160'
    >>> pool = pycassa.ConnectionPool('Keyspace1', server_list=['192.168.2.10'])

See the [tutorial](http://pycassa.github.com/pycassa/tutorial.html#connecting-to-cassandra) for more details.

Basic Usage
-----------

To use the standard interface, create a ColumnFamily instance.

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

insert() also acts to update values:

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

You may insert multiple columns at once:

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

get_range() returns an iterable. Call it with list() to convert it to a list.

    >>> list(cf.get_range())
    [('bar', {'column1': 'val3', 'column2': 'val4'}), ('foo', {'column1': 'val2'})]
{'fraction_non_alphanumeric': 0.16298116298116297, 'fraction_numerical': 0.031777231777231775, 'mean_word_length': 3.9162640901771337, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1289678', 'n_tokens_mistral': 2155, 'n_tokens_neox': 1959, 'n_words': 553}