简体   繁体   English

类型错误:only() 需要 2 个位置参数,但给出了 3 个

[英]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.

相关问题 TypeError:open()接受0个位置参数,但给出了2个 - TypeError: open() takes 0 positional arguments but 2 were given TypeError 接受 2 个位置参数,但给出了 3 个 - TypeError takes 2 positional arguments but 3 were given TypeError: changespeed() 需要 2 个位置 arguments 但给出了 3 个 - TypeError: changespeed() takes 2 positional arguments but 3 were given SQLite:TypeError:query()接受2个位置参数,但给出了4个 - SQLite: TypeError: query() takes 2 positional arguments but 4 were given Python线程“TypeError:_testmethod()需要2个位置参数,但12个被赋予” - Python Threading “TypeError: _testmethod() takes 2 positional arguments but 12 were given” python super:TypeError:__init __()接受2个位置参数,但给出了3个 - python super :TypeError: __init__() takes 2 positional arguments but 3 were given Money 和 TypeError:__init__() 需要 1 到 2 个位置参数,但给出了 3 个 - Money and TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given 类型错误:androlyze_main() 需要 2 个位置参数,但给出了 4 个 - TypeError: androlyze_main() takes 2 positional arguments but 4 were given TypeError:create_purple()接受0个位置参数,但给出了2个 - TypeError: create_purple() takes 0 positional arguments but 2 were given KIVY TypeError:on_keyboard_down()接受2个位置参数,但给出了5个 - KIVY TypeError: on_keyboard_down() takes 2 positional arguments but 5 were given
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM