S
S
Samad_Samadovic2021-06-06 16:45:10
Python
Samad_Samadovic, 2021-06-06 16:45:10

How to use CASE to modify a table?

My code for this is:

cur.execute(f"""SELECT id_(
                                CASE 
                                WHEN id_ > 0 THEN UPDATE Home_work SET {For_lesons[Iug]} = '{CVB}'
                                ELSE INSERT INTO Home_work(Алгебра, Геометрия, Физ_ра, Укр_м, Укр_літ, Русск_яз, Русск_лит, Изо, Нем_яз, География, Англ_яз, Биология, Информатика, Физика, Основы_здоровья, Химия, Музыка, Ист_укр, Всем_ист, Труды_для_м, Труды_для_д) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?), {G})
                                END,
                            FROM Home_work)""")

for_lesons - List of lessons; Iug - Index of a certain lesson; CVB - String
Error:
cur.execute(f"""SELECT id_(
sqlite3.OperationalError: near "UPDATE": syntax error

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question