app.config['CASSANDRA_KEYSPACE'] = "stocks" app.config['CQLENG_ALLOW_SCHEMA_MANAGEMENT'] = True db = CQLAlchemy(app) class Equity(db.Model): equity_name = db.columns.Text(primary_key=True, required=True) equity_timestamp = db.columns.List(db.columns.Text, required=False) equity_open = db.columns.List(db.columns.Text, required=False) equity_high = db.columns.List(db.columns.Text, required=False) equity_low = db.columns.List(db.columns.Text, required=False) equity_close = db.columns.List(db.columns.Text, required=False) equity_volume = db.columns.List(db.columns.Text, required=False) db.sync_db() @app.route('/', methods=['GET']) def get_all_equity_names(): q = Equity.all() count = len(q) name = [] for i in range(count): name.append(q[i]['equity_name']) return jsonify(name) @app.route('/<name>', methods=['GET']) def get_data_by_name(name): q = Equity.all()
app.config['CASSANDRA_HOSTS'] = ['cassandra'] app.config['CASSANDRA_KEYSPACE'] = "genius" app.config['CQLENG_ALLOW_SCHEMA_MANAGEMENT'] = True db = CQLAlchemy(app) #instance created #Model definition for the database class Records(db.Model): artists = db.columns.Text(primary_key=True, required=True) songs = db.columns.List(db.columns.Text, required=False) #lyrics = db.columns.List(db.columns.Text,required=False) db.sync_db() #brings everything to the code from db #Method to get a list of all artists in database @app.route('/', methods=['GET']) def get_artists(): q = Records.all() count = q.count() artists = [] for i in range(count): artists.append(q[i]['artists']) return jsonify(artists) #Method to get a list of all songs by an artist @app.route('/<artist>', methods=['GET'])