我使用PostgreSQL和烧瓶-sqlalchemy创建了一个包含3个表的数据库。我正在查询3个表,只获取它们的it,然后检查它们的it,看看是否有类似的it,然后将相似的一个添加到第三个表中,但是每当我运行它时,我都会得到以下错误
sqlalchemy.exc.ProgrammingError:(Kercopg2.ProgrammingError)无法适应类型'Row‘SQL:插入登录(student_id,名称,时间戳)值(%(Student_id),%(名称)s,%(时间戳)s)
@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)请有人告诉我这个错误意味着什么,以及我为什么要得到它。
发布于 2022-04-16 21:32:44
id是一个查询结果。ids是查询行。要从该行中获得一个值,您需要告诉它哪个列(即使只有一个列):ids['student_id]'。
https://stackoverflow.com/questions/71897602
复制相似问题