sql - python: update an existing sqlite db -
have python script creates sqlite database:
import sqlite3 con = sqlite3.connect('some.db',detect_types=sqlite3.parse_decltypes) con: cur = con.cursor() cur.execute("create table title(id int, ...)")
and later populates db content list:
<id> = <whatever> <var1> = <you point> altogether = (id, var1...) cur.execute("insert title values(?,?,...)", altogether) con.commit()
i want write modified version of script takes existing some.db
, updates it, if id doesn't exist in database.
how i:
open
some.db
read/write update values onlyquery db make sure
id
ofitem
i'm iterating through not exist in db? way i'm populating variables making api calls external service i'd able skip if entry in db.
same way did.
don't. make column
unique
, handle exception oninsert
.
Comments
Post a Comment