Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) can't adapt type 'Row'

I created a database with 3 tables using PostgreSQL and flask-sqlalchemy. I am querying 3 tables to get only their ids then I check their ids to see if there’s any similar one then add the similar one to the third table but anytime i run it i get this error

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)}]

@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)

please could someone tell me what this error means and why I am getting it

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

id is a query result. ids is a query row. To get one value from that row, you need to tell it which column (even if there is only one column): ids['student_id]'.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading