0

我正在尝试创建一个将使用 django ORM 工具的脚本。我也会有一个轻量级的网络界面。

现在,当我运行时:

python manage.py runserver

我可以去 localhost 浏览我的应用程序,添加一些数据,修改等。没问题。但是,当我创建如下脚本时:

import sys
import os
sys.path.append('C:\\hg\eclipse_workspace\dj_MNH')
os.environ["DJANGO_SETTINGS_MODULE"] = "dj_MNH.settings"
from SeN.models import Deliveries as table

def process():
    """ quick test """

    d = table.objects.get(nve_filename='test')
    print d.nve_filetime
    print table.objects.all()


if __name__ == "__main__":
    process()

我在下面得到以下回溯。我有另一个类似配置的 django 项目,它以相同的方式工作,没有问题!我可以打开我的 sqlite 数据库,看看那里也有一些数据......关于什么/如何调试的任何想法?

In [2]: run simple_nvd.py
---------------------------------------------------------------------------
DatabaseError                             Traceback (most recent call last)
C:\Python27\Lib\site-packages\IPython\utils\py3compat.pyc in execfile(fname, glo
b, loc)
    169             else:
    170                 filename = fname
--> 171             exec compile(scripttext, filename, 'exec') in glob, loc
    172     else:
    173         def execfile(fname, *where):

C:\voltest\test\simple_nvd.py in <module>()
     28
     29 if __name__ == "__main__":
---> 30     process()

C:\voltest\test\simple_nvd.py in process(today)
     19 #    print table.objects.all()
     20
---> 21     d = table.objects.get(nve_filename='test')
     22     print d.nve_filetime
     23     print table.objects.all()

C:\Python27\Lib\site-packages\django\db\models\manager.pyc in get(self, *args, *
*kwargs)
    129
    130     def get(self, *args, **kwargs):
--> 131         return self.get_query_set().get(*args, **kwargs)
    132
    133     def get_or_create(self, **kwargs):

C:\Python27\Lib\site-packages\django\db\models\query.pyc in get(self, *args, **k
wargs)
    359         if self.query.can_filter():
    360             clone = clone.order_by()
--> 361         num = len(clone)
    362         if num == 1:
    363             return clone._result_cache[0]

C:\Python27\Lib\site-packages\django\db\models\query.pyc in __len__(self)
     83                 self._result_cache = list(self._iter)
     84             else:
---> 85                 self._result_cache = list(self.iterator())
     86         elif self._iter:
     87             self._result_cache.extend(self._iter)

C:\Python27\Lib\site-packages\django\db\models\query.pyc in iterator(self)
    289             klass_info = get_klass_info(model, max_depth=max_depth,
    290                                         requested=requested, only_load=o
nly_load)
--> 291         for row in compiler.results_iter():
    292             if fill_cache:
    293                 obj, _ = get_cached_row(row, index_start, db, klass_info
,

C:\Python27\Lib\site-packages\django\db\models\sql\compiler.pyc in results_iter(
self)
    761         if self.query.select_for_update and transaction.is_managed(self.
using):
    762             transaction.set_dirty(self.using)
--> 763         for rows in self.execute_sql(MULTI):
    764             for row in rows:
    765                 if resolve_columns:

C:\Python27\Lib\site-packages\django\db\models\sql\compiler.pyc in execute_sql(s
elf, result_type)
    816
    817         cursor = self.connection.cursor()
--> 818         cursor.execute(sql, params)
    819
    820         if not result_type:

C:\Python27\Lib\site-packages\django\db\backends\util.pyc in execute(self, sql,
params)
     38         start = time()
     39         try:
---> 40             return self.cursor.execute(sql, params)
     41         finally:
     42             stop = time()

C:\Python27\Lib\site-packages\django\db\backends\sqlite3\base.pyc in execute(sel
f, query, params)
    342         query = self.convert_query(query)
    343         try:
--> 344             return Database.Cursor.execute(self, query, params)
    345         except Database.IntegrityError, e:
    346             raise utils.IntegrityError, utils.IntegrityError(*tuple(e)),
 sys.exc_info()[2]

DatabaseError: no such table: SeN_deliveries
4

0 回答 0