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:

  1. open some.db read/write update values only

  2. query db make sure idof item 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.

  1. same way did.

  2. don't. make column unique , handle exception on insert.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -