예제 #1
0
파일: __init__.py 프로젝트: stt/eve-peewee
 def _get_driver(self, dburi):
     """assigns eve.data.driver based on config.DATABASE_URI
     Override for any atypical db needs
     """
     # NOTE: if there's an uncaptured db exception and rollback doesn't
     # happen then the site is down until restart, could do autorollback=True?
     parsed = db_url.urlparse(dburi)
     class RetryDB(RetryOperationalError, db_url.schemes[parsed.scheme]):
         pass
     return RetryDB(**db_url.parse(dburi))
예제 #2
0
def connect(url, **connect_params):
    """Support async databases."""
    parsed = urlparse(url)
    connect_kwargs = parseresult_to_dict(parsed)
    connect_kwargs.update(connect_params)
    database_class = schemes.get(parsed.scheme)

    if database_class is None:
        if database_class in schemes:
            raise RuntimeError('Attempted to use "%s" but a required library '
                               'could not be imported.' % parsed.scheme)
        raise RuntimeError('Unrecognized or unsupported scheme: "%s".' % parsed.scheme)

    return database_class(**connect_kwargs)
예제 #3
0
def connect(url, **connect_params):
    """Support async databases."""
    parsed = urlparse(url)
    connect_kwargs = parseresult_to_dict(parsed)
    connect_kwargs.update(connect_params)
    database_class = schemes.get(parsed.scheme)

    if database_class is None:
        if database_class in schemes:
            raise RuntimeError('Attempted to use "%s" but a required library '
                               'could not be imported.' % parsed.scheme)
        raise RuntimeError('Unrecognized or unsupported scheme: "%s".' %
                           parsed.scheme)

    return database_class(**connect_kwargs)