Dear Friends of Web2Py,
I am using the python shell within Web2Py  
http://127.0.0.1:8000/admin/shell/index/welcome.
I created a small database called person with 1 field called name. I
inserted a few records and then queried the database table and printed
a set of rows. Then on a next query it gives the error message
"ProgrammingError: Cannot operate on a closed database."
How to avoid this or go on with the database work in the shell? see
MDIPierro answer at bottom from 2009

db.define_table('person', Field('name'))
person = db.person
person.insert(name='Carl')
person.insert(name='Alexis)
for row in db(person).select():
  print row.name
>>>Carl
      Alexis

for row in db(person).select(orderby=db.person.name):
  print row.name
>>>Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "gluon/dal.py", line 5164, in select
  File "gluon/dal.py", line 1077, in select
  File "gluon/dal.py", line 1067, in response
  File "gluon/dal.py", line 1152, in execute
  File "gluon/dal.py", line 1147, in log_execute
ProgrammingError: Cannot operate on a closed database.

db.person.insert(name='Peggy')
>>>Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "gluon/dal.py", line 4487, in insert
  File "gluon/dal.py", line 772, in insert
ProgrammingError: Cannot operate on a closed database.

on dec.15 2009 in  forum:
This is not a new problem unfortunately. There is some timeout issue
with the sqlite diver. The problems is that the connection needs to be
open server side for as long as the shell is open but the driver does
not allow it. I have not found a way around this yet.

If you or anybody has idea of how to solve this please let me know.

Massimo




Reply via email to