搜索准备用djangosphinx,python manage.py generate_sphinx_config[questions]>>d:\sphinx\bin\sphinx.conf时出现错误
File "C:\Python27\lib\site-packages\django_sphinx-2.2.4-py2.7.egg\djangosphinx
\utils\config.py", line 51, in <module>
'database_engine': _get_database_engine(),
File "C:\Python27\lib\site-packages\django_sphinx-2.2.4-py2.7.egg\djangosphinx
\utils\config.py", line 18, in _get_database_engine
raise ValueError, "Only MySQL and PostgreSQL engines are supported by Sphinx
."
ValueError: Only MySQL and PostgreSQL engines are supported by Sphinx.
51行为:
DEFAULT_SPHINX_PARAMS = {
'database_engine': _get_database_engine(),
'database_host': settings.DATABASE_HOST,
'database_port': settings.DATABASE_PORT,
'database_name': settings.DATABASE_NAME,
'database_user': settings.DATABASE_USER,
'database_password': settings.DATABASE_PASSWORD,
'log_file': '/var/log/sphinx/searchd.log',
'data_path': '/var/data',
}
找到config.py,_get_database_engine函数为:
def _get_database_engine():
if settings.DATABASE_ENGINE == 'mysql':
return settings.DATABASE_ENGINE
elif settings.DATABASE_ENGINE.startswith('postgresql'):
return 'pgsql'
raise ValueError, "Only MySQL and PostgreSQL engines are supported by Sphinx."
调用了django.conf.setting的DATABASE_ENGINE,用于判断数据库类型,我用的是mysql,将其直接改为
def _get_database_engine():
return 'mysql'
成功。