SQLite in Python(3) UPDATE, DELETE

0

ํŒŒ์ด์ฌ(Python)

๋ชฉ๋ก ๋ณด๊ธฐ
5/7

UPDATE ~ SET ~ WHERE ~

You can change value of table by using UPDATE. It is simple. Look at the next line๐Ÿ˜™ Don't forget about 'commit()' or data doesn't change as you think.

c.execute("UPDATE users SET username=? WHERE id=?", ("Jong", 3))
conn.commit()
c.execute("UPDATE users SET username='%s' WHERE id='%s'" % ("Jong", 3))
conn.commit()
c.execute("UPDATE users SET username=:name WHERE id=:id", {"name":"Jong", "id":3})
conn.commit() 

DELETE FROM ~ WHERE

You can delete data of table๐Ÿคซ

c.execute("DELETE FROM users WHERE id = ?", (2,))

0๊ฐœ์˜ ๋Œ“๊ธ€