sqlalchemy.exc.ProgrammingError:(psycopg2.ProgrammingError)无法适应类型“行”

Ala*_*eph 7 python postgresql sqlalchemy flask flask-sqlalchemy

我使用 PostgreSQL 和flask-sqlalchemy 创建了一个包含 3 个表的数据库。我正在查询 3 个表以仅获取它们的 id,然后检查它们的 id 以查看是否有任何相似的 ID,然后将相似的表添加到第三个表,但每当我运行它时,我都会收到此错误

sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) can't adapt type 'Row' 
[SQL: INSERT INTO login (student_id, name, timestamp) VALUES (%(student_id)s, %(name)s, %(timestamp)s)] 
[parameters: {'student_id': (1234567,), 'name': None, 'timestamp': datetime.datetime(2022, 4, 16, 21, 10, 53, 30512)}]
Run Code Online (Sandbox Code Playgroud)
@app.route('/')
def check():
id = Esp32.query.with_entities(Esp32.student_id).all()
students = Student.query.with_entities(Student.student_id).all()
logins = Login.query.with_entities(Login.student_id).all()
for ids in id:   
    if ids in students and ids not in logins:
        new = Login(student_id= ids)
        db.session.add(new)
        db.session.commit()
return render_template('check.html', newlog = new)
Run Code Online (Sandbox Code Playgroud)

请有人告诉我这个错误意味着什么以及为什么我会收到它

Tim*_*rts 8

id是一个查询结果。 ids是一个查询行。要从该行获取一个值,您需要告诉它是哪一列(即使只有一列):ids['student_id]'