you mean include 'print db.tables' in the script? if you mean run 'print db.tables' in the shell to test my connection to the db, I've done that and it shows all my tables, until I run the script. At that point, I can no longer access the tables in the shell.
I did read in an external site about web2py crontab that all cron scripts should have "db.commit()" at the end of each function with a query, so perhaps that's what's happening. On Aug 24, 12:33 pm, Massimo Di Pierro <massimo.dipie...@gmail.com> wrote: > try print db.tables > > On Aug 24, 10:55 am, Eric Scott <erictransla...@gmail.com> wrote: > > > > > > > > > I'm having trouble running a module in the web2py shell. It's having > > difficulty with a db query that I execute with no problems in any > > controller. Here's the traceback: > > > Traceback (most recent call last): > > File "<console>", line 1, in <module> > > File "/home/www-data/web2py/gluon/custom_import.py", line 280, in > > __call__ > > fromlist, level) > > File "/home/www-data/web2py/gluon/custom_import.py", line 74, in > > __call__ > > level) > > File "applications/baristacode/modules/real_addcard.py", line 37, in > > <module> > > rows = db(db.card.number==cardnum).select() > > File "/home/www-data/web2py/gluon/dal.py", line 4331, in __getattr__ > > return self[key] > > File "/home/www-data/web2py/gluon/dal.py", line 4325, in __getitem__ > > return dict.__getitem__(self, str(key)) > > KeyError: 'card' > > > I use "python web2py.py -S app -M" and I always check to be sure the > > db is available in the shell, as well as the models. I'm also able to > > execute the query by itself in the shell, but when it's in a module, I > > get the KeyError above. > > > I've tried importing the module and using execfile, and in both cases > > the script runs fine until the first db query. > > > Any hints or suggestions? > > > Thank you, > > > Eric