#1 ?
c.execute('SELECT * FROM users WHERE id =?',(2,))
print(c.fetchone())
#2 %ํฌ๋ฉง์ด์ฉ
c.execute('SELECT * FROM users WHERE id = "%s" ' %13)
print(c.fetchall())
#3 ๋์ ๋๋ฆฌ ์ด์ฉ
c.execute('SELECT * FROM users WHERE id = ID',{"ID":23})
print(c.fetchone())
# ๋๊ฐ ์ด์์ row ๊ฐ์ ธ์ค๊ธฐ
#1
p = (2,33)
c.execute("SELECT * FROM users WHERE id IN(?,?)",p)
print(c.fetchall())
#2 OR ์ด์ฉ
c.execute("SELECT * FROM users WHERE id=:id1 OR id=:id2",{"id1":2,"id2":5})
print(c.fetchall())
# 1. ?
c.execute("UPDATE users SET username = ? WHERE id = ?",('you','2'))
#2. ๋์ ๋๋ฆฌ
c.execute("UPDATE users SET username = :new_name WHERE id = :ID", {"new_name":"park", "ID":2})
#3. %ํฌ๋ฉง
c.execute("UPDATE users SET username = '%s' WHERE id = '%s'"%('park',2))
*๋ฐ์ดํฐ ์ญ์ (delete)
#1. ?
c.execute("DELETE FROM users WHERE id = ?", (2,))
#2. ๋์ ๋๋ฆฌ
c.execute("DELETE FROM users WHERE id = :ID",{"ID":5})
#3. %ํฌ๋ฉง
c.execute("DELETE FROM users WHERE id = '%s'" %13)