Simple sqlite3 question

cjl cjlesh at
Tue Apr 24 19:03:45 CEST 2007


I am using python 2.5.1 on windows. I have the following code:

conn = sqlite3.connect('.\optiondata')
c = conn.cursor()
    c.execute('''create table options (ssymbol text, strike real,
osymbol text, bid real, mpp real, upp real)''')
except sqlite3.OperationalError:

I am hoping the above code creates a new database file named
'optiondata' with a single table named 'options', or connects to it if
already created. Am I off the mark here?

I also have a function that does the following:

c.execute("""insert into options values (?,?,?,?,?,?)""",data)

When I run the script and there is no file named optiondata, one is
created and the correct data is added to it.  If I run the script
again then the data from the first run seems to be replaced with the
data from the second run. I expected that the data from the second run
would be appended to the database file, not replace it.

Can anyone point me in the right direction to get the expected


More information about the Python-list mailing list