8

Click here to load reader

Python & Cassandra - Best Friends

Embed Size (px)

DESCRIPTION

Python is a great programming language that works great with Cassandra. If your goal is to get your project into production quickly and iterate fast, Python is a great solution. These slides are an introduction to the hands on portion from GitHub. https://github.com/rustyrazorblade/python-presentation

Citation preview

Page 1: Python & Cassandra - Best Friends

©2013 DataStax Confidential. Do not distribute without consent.

@rustyrazorblade

Jon HaddadTechnical Evangelist,Datastax

Python & Cassandra, Best Friends

1

Page 2: Python & Cassandra - Best Friends

Virtual Environments• Isolated environment per project • Build into Python 3.4, available • 3rd party lib in Python 2.7

• pip install virtualenvwrapper• Add to your shell startup file: • source /usr/local/bin/virtualenvwrapper.sh

Page 3: Python & Cassandra - Best Friends

Before we start• If you'd like to follow along locally, please: • have cassandra running • clone [email protected]:rustyrazorblade/python-presentation.git • create a virtualenv • mkvirtualenv tutorial• install requirements • pip install -r requirements.txt• Start the notebook • ipython notebook

Page 4: Python & Cassandra - Best Friends

Why Python?• Python is easy to read & write • Python is mature • It takes less time to develop an app in Python • Lots of existing libraries • Principle of least astonishment

•You can be out the door and iterating while the other dev is still working • In most applications, most time is spent waiting on the database •Dev time is usually more costly than the extra server •Correct data model will save you more time than faster app code •Focus on architecture

Page 5: Python & Cassandra - Best Friends

Native Driver Overview• Provides means of connecting to a cluster and executing CQL3 queries • cassandra.cluster.Cluster keeps track of servers & schema • cassandra.cluster.Session manages connection pool • Cluster.metadata has keyspace, table information • Provides concurrency through cassandra.concurrency• session.execute()

Page 6: Python & Cassandra - Best Friends

cqlengine overview• Community project (but moving to DataStax) • Created by me & Blake Eggleston (also now at DataStax) • Object mapper on top of the native driver • Removes the need to write most CQL queries manually • Define models, work with regular python types

Page 7: Python & Cassandra - Best Friends

NO MORE SLIDES!

Page 8: Python & Cassandra - Best Friends

©2013 DataStax Confidential. Do not distribute without consent. 8