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


Download files

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

Source Distribution

Flask-CassandraDB-0.0.1.tar.gz (2.6 kB view details)

Uploaded Source

File details

Details for the file Flask-CassandraDB-0.0.1.tar.gz.

File metadata

File hashes

Hashes for Flask-CassandraDB-0.0.1.tar.gz
Algorithm Hash digest
SHA256 678b9c21a5ff6828d863cd9e51f460b96716f962171967286cebe12cf809fc06
MD5 bd855df8d70dfd87dbd864e3fea6b17f
BLAKE2b-256 bb777c8e7258b6200a6d5b69b9f9179bbf986ed4cc6b182a6c54ae7ad6e6b96c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page