未定义web2py db

2024-04-19 17:39:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在命令行运行一个脚本,该脚本使用带有以下命令的模型:

c:\web2py>python web2py.py -M -N -S automate -R applications/automate/modules/eventserver.py

但我一直有个错误:

web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.99.7 (2012-03-04 22:12:08) stable
Database drivers available: SQLite3, pymysql, pg8000, IMAP
Traceback (most recent call last):
  File "c:\web2py\gluon\shell.py", line 206, in run
    execfile(startfile, _env)
  File "applications/automate/modules/eventserver.py", line 6, in <module>
    deviceHandler = devicehandler.DeviceHandler()
  File "applications\automate\modules\devicehandler.py", line 10, in __init__
    self.devices = self.getActiveDevices()
 File "applications\automate\modules\devicehandler.py", line 18, in getActiveDe
vices
    print db
NameError: global name 'db' is not defined

我做错什么了?

编辑:从我的研究中,我只找到了“在你的命令中添加-M”的解决方案,但我已经这么做了,它仍然不起作用。

edit2:db.py中有db=DAL('sqlite://storage.sqlite'),因此应该加载它


Tags: inpy命令self脚本modulesdbsqlite