Re: Cursor Not Passed Properly Inter-Module

[email protected]
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <OFD22EDE69.AC0E6EBB-ON85257235.004411C1-85257235.004466CA@bankofny.com>
How about this you call

DBtools().SaveDB(self.appData.dbFileName)

But right above it you have:

DBtools.cur.execute("insert or replace into model (model_name, \
                           model_desc, model_type, \
                           keName, agent) values (self.modnName, \
                           self.modDesc, self.modType, \
                           self.knowlEng, self.method)"

Does the line:

DBtools().cur.execute("insert or replace into model (model_name, \
                           model_desc, model_type, \
                           keName, agent) values (self.modnName, \
                           self.modDesc, self.modType, \
                           self.knowlEng, self.method)"

Work better,

You can do some thing like

dba = DBtools()
dba.CreateDB(filename)
dba.cur.execute("insert ...")

or you can call the class like with the DBtools()

Nowhere do you assign so DBtools does not have a cur variable


Thanks,

Greg Givler
Information Technology
Lockwood®
10 Valley Stream Parkway
Malvern, PA 19355
Phone: (484) 605-4826
Email: [email protected]


                                                                                                                                           
                      Rich Shepard                                                                                                         
                      <rshepard@appl-ecosys        To:       "For users of the pysqlite database module." <pysqlite-IAPFreCvJWPBWskQ1e/[email protected]>       
                      .com>                        cc:                                                                                     
                      Sent by:                     Subject:  Re: [pysqlite] Cursor Not Passed Properly Inter-Module                        
                      pysqlite-bounces@list                                                                                                
                      s.initd.org                                                                                                          
                                                                                                                                           
                                                                                                                                           
                      11/28/2006 08:40 PM                                                                                                  
                      Please respond to                                                                                                    
                      "For users of the                                                                                                    
                      pysqlite database                                                                                                    
                      module."                                                                                                             
                                                                                                                                           
                                                                                                                                           




On Tue, 28 Nov 2006, William J Chapman wrote:

> You seen to be wanting to call methods on class DBtools without first
> creating an instance.  You appear to call the DBtools constructor
(i.e.,
> DBtools().CreateDB(...)) in OnNewMod() but don't save a reference.
Then in
> OnSaveMod() you invoke DBtools.cur.exectue(...), but you don't appear
to
> specify the instance of DBtools to use.

Bill,

   Thanks. I tried creating instances, but that did not solve the
problem.
There's no problem calling methods in DBtools(), but there was in trying
to
access the cursor.

   I solved that by putting a copy of the connection and cursor in the
generic configData() class that's imported by all other modules.

   Perhaps you have some insight into why the data seem to be written to
the
table via the open cursor, but they're not there. No error messages
offered
by python or pysqlite. I just posted that to the list.

   One of these days I'll get past the learning curve and be more
productive
and less questioning.

Rich

--
Richard B. Shepard, Ph.D.               |    The Environmental
Permitting
Applied Ecosystem Services, Inc.(TM)    |            Accelerator
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax:
503-667-8863
_______________________________________________
pysqlite mailing list
pysqlite-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/pysqlite

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please call the help desk at ext 4850
______________________________________________________________________




______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
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.