Cursor Not Passed Properly Inter-Module
Rich Shepard <[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
While I thought I had this written correctly, testing proves me incorrect.
One module, named 'dbMethods.py,' has the class DBTools with several
methods. The initial lines are:
class DBtools:
appData = config.appData
def CreateDB(self, dbFileName):
con = None
cur = None
if not con:
con = sqlite3.connect(self.appData.dbFileName)
cur = con.cursor()
""" Overall model information """
cur.execute("CREATE TABLE model (model_name TEXT NOT NULL \
PRIMARY KEY, model_desc TEXT, model_type TEXT, \
keName TEXT, agent INTEGER);")
This was modeled on the usage guide.
Another module, named 'modelPage.py,' starts with
from dbMethods import DBtools
then calls the CreateDB() method as:
dba = DBtools().CreateDB(self.appData.dbFileName)
The error message presented by pthon is:
Traceback (most recent call last):
File "/data1/eikos/modelPage.py", line 202, in OnSaveMod
dba = DBtools.cur.execute("insert or replace into model (model_name,
model_desc, model_type, \
AttributeError: class DBtools has no attribute 'cur'
This may be a mis-used or missing 'self', but when I insert print
statements in CreateDB() after the connection and cursor are defined, they
show up as existing.
A clue stick gently applied would be very helpful.
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