我有以下用 python 编写的代码,以便使用 eulexistdb 模块与 ExistDB 通信。
from eulexistdb import db
class TryExist:
def __init__(self):
self.db = db.ExistDB(server_url="http://localhost:8899/exist")
def get_data(self, query):
result = list()
qresult = self.db.executeQuery(query)
hits = self.db.getHits(qresult)
for i in range(hits):
result.append(str(self.db.retrieve(qresult, i)))
return result
quer = '''
let $x:= doc("/db/sample/books.xml")
return $x/bookstore/book/author/text()
'''
a = TryExist()
myres = a.get_data(quer)
print myres
我很惊讶这段代码在 Aptana Studio 3 中运行良好,给了我想要的输出,但是当从其他 IDE 运行或使用命令“python.exe myfile.py”时会出现以下错误:
django.core.exceptions.ImproperlyConfigured: Requested setting EXISTDB_TIMEOUT, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
我使用自己的 localsetting.py 使用以下代码解决了这个问题:
import os
# must be set before importing anything from django
os.environ['DJANGO_SETTINGS_MODULE'] = 'localsettings'
... writing link for existdb here...
然后我得到错误:
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
如何在 Django 中配置设置以适应 ExistDB?请帮帮我..