Reputation: 135
Here I am trying to get only two fields from cassandra using only() but when I am passing field names it's giving me above error, I have also tried passing self but did't work. After getting those two fields I need to convert them in two arrays so that I can plot the graph with names and marks.
Here is the code:
from flask import *
from flask_cqlalchemy import CQLAlchemy
app = Flask(__name__)
app.config['CASSANDRA_HOSTS'] = ['127.0.0.1']
app.config['CASSANDRA_KEYSPACE'] = "emp"
db = CQLAlchemy(app)
class Student(db.Model):
uid = db.columns.Integer(primary_key=True)
marks = db.columns.Integer(primary_key=True)
username = db.columns.Text(required=True)
password = db.columns.Text()
@app.route('/meriting')
def show_meritlist():
ob = Student.objects().filter().only(Student.marks, Student.username)
ob = ob.filter(Student.marks >= 65).allow_filtering()
return render_template('merit.html', ml = ob)
db.sync_db()
if __name__ == '__main__':
app.run(debug = True)
Upvotes: 1
Views: 4544
Reputation: 1553
only()
takes only one parameter that should be an iterable. Try:
ob = Student.objects().filter().only((Student.marks, Student.username))
Upvotes: 2