[英]TypeError: only() takes 2 positional arguments but 3 were given
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.在这里,我试图仅使用 only() 从 cassandra 获取两个字段,但是当我传递字段名称时,它给了我上述错误,我也尝试传递self但没有用。 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)
only()
takes only one parameter that should be an iterable. only()
只接受一个应该是可迭代的参数。 Try:尝试:
ob = Student.objects().filter().only((Student.marks, Student.username))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.