django-oraclepool 未找到异常
Posted
技术标签:
【中文标题】django-oraclepool 未找到异常【英文标题】:django-oraclepool not found exception 【发布时间】:2014-09-15 07:18:38 【问题描述】:我需要一个用于 django(和 oracle 数据库)的会话池。 我找到了这个https://pypi.python.org/pypi/django-oraclepool。但是如何使用呢?
我进行了 pip 安装并将以下行添加到 settings.py(我在 http://pydoc.net/Python/django-oraclepool/1.2/oraclepool.tests.settings/ 找到它)
INSTALLED_APPS = (
'oraclepool',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'axes',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'axes.middleware.FailedLoginMiddleware'
)
EXTRAS = 'min':4, # start number of connections
'max':8, # max number of connections
'increment':2, # increase by this amount when more are needed
'homogeneous':1, # 1 = single credentials, 0 = multiple credentials
'threaded':True, # server platform optimisation
'timeout':10, # connection timeout, 600 = 10 mins
'log':0, # extra logging functionality
'logpath':'.', # file system path to log file
'existing':'Unicode', # Type modifications if using existing database data
'session': ["alter session set session_cached_cursors = 8;",
"alter session set cursor_sharing = 'SIMILAR'"]
CREDENTIALS = 'USER' : '####',
'NAME' : 'xe',
'PASSWORD' : '####',
'HOST' : '####',
'PORT' : '7854',
'OPTIONS' :
DATABASES= 'oraclepool':'ENGINE' : 'oraclepool',
'EXTRAS' : EXTRAS
,
'oracle':'ENGINE' : 'django.db.backends.oracle',
'EXTRAS' : 'existing':'Unicode'
for db in ['oraclepool','oracle']:
for key in CREDENTIALS.keys():
DATABASES[db][key] = CREDENTIALS[key]
DATABASES['default'] = DATABASES['oraclepool']
但是当我想运行我的 django 项目时,我得到了这个错误:
ImportError: No module named 'oraclepool'
...
django.core.exceptions.ImproperlyConfigured: 'oraclepool' isn't an available dat
abase backend.
Try using 'django.db.backends.XXX', where XXX is one of:
'mysql', 'oracle', 'postgresql_psycopg2', 'sqlite3'
Error was: No module named 'oraclepool'
我是否遗漏了一个步骤或代码行?
【问题讨论】:
【参考方案1】:您可以在名称中添加pooled
参数。像这样:
DATABASES =
'default':
'ENGINE': 'django.db.backends.oracle',
'NAME': '#####/XE:POOLED',
'USER':'#####',
'PASSWORD':'#####',
【讨论】:
以上是关于django-oraclepool 未找到异常的主要内容,如果未能解决你的问题,请参考以下文章