def _discover_ideal_backend(orm_backend):
"""Auto-discover the ideal backend based on what is installed.
Right now, handles discovery of:
* PeeWee
* SQLAlchemy
Args:
orm_backend (str): The ``orm_backend`` value that was passed to the
``create_app`` function. That is, the ORM Backend the User
indicated they wanted to use.
Returns:
str|fleaker.missing.MissingSentinel: Returns a string for the ideal
backend if it found one, or :obj:`fleaker.MISSING` if we couldn't
find one.
Raises:
RuntimeError: Raised if no user provided ORM Backend is given and BOTH
PeeWee and SQLAlchemy are installed.
"""
if orm_backend:
return orm_backend
if peewee is not MISSING and sqlalchemy is not MISSING:
raise RuntimeError('Both PeeWee and SQLAlchemy detected as installed, '
'but no explicit backend provided! Please specify '
'one!')
if peewee is not MISSING:
return _PEEWEE_BACKEND
elif sqlalchemy is not MISSING:
return _SQLALCHEMY_BACKEND
else:
return MISSING
评论列表
文章目录