programming/python
[python sqlite3]? Placeholder / Named Placeholder
ba0bab
2018. 8. 26. 12:47
import
sqlite3
conn
=
sqlite3.connect(
"test.db"
)
cur
=
conn.cursor()
sql
=
"select * from customer where category=? and region=?"
cur.execute(sql, (
1
,
'SEA'
))
rows
=
cur.fetchall()
for
row
in
rows:
print
(row)
conn.close()
#Named
sql
=
"select * from customer where id = :Id"
cur.execute(sql, {
"Id"
:
1
})