Skip to content
Provides a Flask extension to access Apache Cassandra databases
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE
README.md
flask_cassandra.py
setup.py

README.md

Flask-Cassandra

Flask-Cassandra provides an application-level connection to an Apache Cassandra database. This connection can be used to interact with a Cassandra cluster.

Flask-Cassandra requires both Flask and the Datastax Python Driver for Apache Cassandra to be installed. This driver will be installed automatically when installing via pip or when running setup.py install.

Installation

The easiest way to use the extension is to install it from PyPI using pip:

$ pip install flask-cassandra

You can also install the extension directly from source.

$ python setup.py install

Use

This is an example flask app that reads from a Cassandra cluster.

from flask import Flask
from flask_cassandra import CassandraCluster

app = Flask(__name__)
cassandra = CassandraCluster()

app.config['CASSANDRA_NODES'] = ['cassandra-c1.terbiumlabs.com']  # can be a string or list of nodes

@app.route("/cassandra_test")
def cassandra_test():
    session = cassandra.connect()
    session.set_keyspace("monty_python")
    cql = "SELECT * FROM sketches LIMIT 1"
    r = session.execute(cql)
    return str(r[0])

if __name__ == '__main__':
    app.run()

Contributions

If you would like to extend the functionality of the extension, pull requests are most welcome.

You can’t perform that action at this time.