Skip to main content

connect cassandra to flask

Project description

Latest PyPI version Latest Travis CI build status

connect cassandra to flask

Usage

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

from flask import Flask
from flask_cassandradb import CassandraCluster

app = Flask(__name__)
cassandra = CassandraCluster()

app.config['CASSANDRA_NODES'] = ['cassandra01.flyzen.com']  # can be a string or list of nodes
app.config['CASSANDRA_KEYSPACE'] = 'pythonista' # default keyspace


@app.route("/cassandra_test")
def cassandra_test():
    session = cassandra.connect("monty_python") # connect to the monty_python keyspace, it not specified will use the default keyspace.
    cql = "SELECT * FROM sketches LIMIT 1"
    r = session.execute(cql)
    return str(r[0])

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

Installation

$ pip install flask-cassandradb

Requirements

Compatibility

Licence

Authors

Flask-CassandraDB was written by Young King.

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for Flask-CassandraDB, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size Flask-CassandraDB-0.0.1.tar.gz (2.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page