Re: Getting started

"Markus Gritsch" <[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
On 06/12/2007, Thomas Heller <[email protected]> wrote:
> I'm trying to get started with pysqlite.  Trying a modified sample from the
> python 2.5 docs:
>
> <code>
> import os
>
> do_create = not os.path.exists("./test.db3")
>
> import sqlite3
> conn = sqlite3.connect("./test.db3")
> c = conn.cursor()
>
> if do_create:
>     # Create table
>     c.execute('''create table stocks
>     (date text, trans text, symbol text,
>      qty real, price real)''')
>
>     # Insert a row of data
>     c.execute("""insert into stocks
>               values ('2006-01-05','BUY','RHAT',100,35.14)""")
>
>
> c.execute("""select * from stocks""")
> for row in c:
>     print row
>
> <code/>
>
> Running the code the first time, the file ./test.db3 is created
> and the one row is listed fine.  Running the code the second time,
> nothing is listed.
>
> Why is the row not written to disk, and what should I do so that
> it will be written?

conn.commit()

Markus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.