Re: Disappearing Data
Adrian Klaver <[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
On Tuesday 28 November 2006 05:36 pm, Rich Shepard wrote:
> With the patient help of Adrian I fixed the cursor-not-found problem by
> copying the connection and cursor to config.py's configData() class which
> is imported by all modules. That's working now.
>
> However, and I wonder when it all gets easier, now my entered data are
> not being written to the database, but there are no pysqlite or python
> errors thrown. I put a bunch of print statements in the method to track
> progress:
>
> def OnSaveMod(self, event):
> modName = self.tcName.GetValue()
> modDesc = self.tcDesc.GetValue()
> modType = self.rb.GetString(self.rb.GetSelection())
> knowlEng = self.keName.GetValue()
> method = self.agent.GetSelection()
> values = (modName, modDesc, modType, knowlEng, method)
> print values
> self.appData.cur.execute("insert or replace into model (model_name, \
> model_desc, model_type, \
> keName, agent) values (?,?,?,?,?)", values)
> print "Just tried to enter data in table."
> DBtools().SaveDB(self.appData.dbFileName)
> print "Returned from DBtools.SaveDB"
>
> What I see on the console is:
>
> (u'foobar', u'Model for testing development.', u'Fuzzy reasoning', u'Rich',
> -1) Just tried to enter data in table.
> Returned from DBtools.SaveDB
>
> If my interpretation is correct, the data were inserted into the table
> 'model' (no errors thrown), and everthing looks good. But, when I run
> sqlite from the command line and go look at that table, nothing's there:
>
> [rshepard@salmo /data1/eikos]$ sqlite3 foobar.db
> SQLite version 3.3.6
> Enter ".help" for instructions
> sqlite> select * from model;
> sqlite>
>
> How do I go about finding what broke when there are no error messages or
> other diagnostics?
>
> Thanks,
>
> Rich
Generally this indicates that a con.commit() has not been issued. The data was
written in the session but rolled back when the session was left without
issuing a commit(). See section 5 of the usage guide. In particular the part
about setting isolation level to None. This sets the connection to
autocommit.
--
Adrian Klaver
[email protected]