I'd like to know, if there are some Situation that These two Kinds Code will have different results?
The 1st:
cur.execute('''INSERT OR REPLACE INTO Member
(user_id, course_id) VALUES ( ?, ? )''',
( user_id, course_id ) )
cur.execute('''UPDATE Member SET role = ?
WHERE user_id = ? AND course_id = ?''',
(role, user_id, course_id))
The 2nd:
cur.execute('''INSERT OR REPLACE INTO Member
(user_id, course_id, role ) VALUES ( ?, ?, ? )''',
( user_id, course_id, role ) )
Here is the Definition of this table:
CREATE TABLE Member (
user_id INTEGER,
course_id INTEGER,
role INTEGER,
PRIMARY KEY (user_id, course_id)
)
Aucun commentaire:
Enregistrer un commentaire