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))
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)