diff --git a/rhodecode/config/environment.py b/rhodecode/config/environment.py --- a/rhodecode/config/environment.py +++ b/rhodecode/config/environment.py @@ -6,18 +6,18 @@ import logging from mako.lookup import TemplateLookup from pylons.configuration import PylonsConfig from pylons.error import handle_mako_error -from sqlalchemy import engine_from_config import rhodecode.lib.app_globals as app_globals import rhodecode.lib.helpers from rhodecode.config.routing import make_map from rhodecode.lib import celerypylons +from rhodecode.lib import engine_from_config +from rhodecode.lib.timerproxy import TimerProxy from rhodecode.lib.auth import set_available_permissions from rhodecode.lib.utils import repo2db_mapper, make_ui, set_rhodecode_config from rhodecode.model import init_model from rhodecode.model.scm import ScmModel -from rhodecode.lib.timerproxy import TimerProxy log = logging.getLogger(__name__) diff --git a/rhodecode/lib/__init__.py b/rhodecode/lib/__init__.py --- a/rhodecode/lib/__init__.py +++ b/rhodecode/lib/__init__.py @@ -79,3 +79,22 @@ def safe_unicode(_str, from_encoding='ut u_str = unicode(_str, from_encoding, 'replace') return u_str + + +def engine_from_config(configuration, prefix='sqlalchemy.', **kwargs): + """ + Custom engine_from_config functions that makes sure we use NullPool for + file based sqlite databases. This prevents errors on sqlite. + + """ + from sqlalchemy import engine_from_config as efc + from sqlalchemy.pool import NullPool + + url = configuration[prefix + 'url'] + + if url.startswith('sqlite'): + kwargs.update({'poolclass':NullPool}) + + return efc(configuration, prefix, **kwargs) + +