#NEWLINE# def create( self , name_or_url , **kwargs ) : #NEWLINE# #INDENT# u = url . make_url ( name_or_url ) #NEWLINE# dialect_cls = u . get_dialect ( ) #NEWLINE# if kwargs . pop ( '_coerce_config' , False ) : #NEWLINE# #INDENT# def pop_kwarg( key , default = None ) : #NEWLINE# #INDENT# value = kwargs . pop ( key , default ) #NEWLINE# if ( key in dialect_cls . engine_config_types ) : #NEWLINE# #INDENT# value = dialect_cls . engine_config_types [ key ] ( value ) #NEWLINE# #UNINDENT# return value #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# pop_kwarg = kwargs . pop #NEWLINE# #UNINDENT# dialect_args = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for k in util . get_cls_kwargs ( dialect_cls ) : #NEWLINE# #INDENT# if ( k in kwargs ) : #NEWLINE# #INDENT# dialect_args [ k ] = pop_kwarg ( k ) #NEWLINE# #UNINDENT# #UNINDENT# dbapi = kwargs . pop ( 'module' , None ) #NEWLINE# if ( dbapi is None ) : #NEWLINE# #INDENT# dbapi_args = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for k in util . get_func_kwargs ( dialect_cls . dbapi ) : #NEWLINE# #INDENT# if ( k in kwargs ) : #NEWLINE# #INDENT# dbapi_args [ k ] = pop_kwarg ( k ) #NEWLINE# #UNINDENT# #UNINDENT# dbapi = dialect_cls . dbapi ( ** dbapi_args ) #NEWLINE# #UNINDENT# dialect_args [ 'dbapi' ] = dbapi #NEWLINE# dialect = dialect_cls ( ** dialect_args ) #NEWLINE# ( cargs , cparams ) = dialect . create_connect_args ( u ) #NEWLINE# cparams . update ( pop_kwarg ( 'connect_args' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) #NEWLINE# pool = pop_kwarg ( 'pool' , None ) #NEWLINE# if ( pool is None ) : #NEWLINE# #INDENT# def connect( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return dialect . connect ( * cargs , ** cparams ) #NEWLINE# #UNINDENT# except dialect . dbapi . Error as e : #NEWLINE# #INDENT# invalidated = dialect . is_disconnect ( e , None , None ) #NEWLINE# util . raise_from_cause ( exc . DBAPIError . instance ( None , None , e , dialect . dbapi . Error , connection_invalidated = invalidated ) ) #NEWLINE# #UNINDENT# #UNINDENT# creator = pop_kwarg ( 'creator' , connect ) #NEWLINE# poolclass = pop_kwarg ( 'poolclass' , None ) #NEWLINE# if ( cargs is None ) : #NEWLINE# #INDENT# poolclass = dialect_cls . get_pool_class ( u ) #NEWLINE# #UNINDENT# pool_args = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# translate = { #NEWLINE# #INDENT# 'logging_name' : 'pool_logging_name' , #NEWLINE# 'echo' : 'echo_pool' , #NEWLINE# 'timeout' : 'pool_timeout' , #NEWLINE# 'recycle' : 'pool_recycle' , #NEWLINE# 'events' : 'pool_events' , #NEWLINE# 'use_threadlocal' : 'pool_threadlocal' , #NEWLINE# 'reset_on_return' : 'pool_reset_on_return' , #NEWLINE# #UNINDENT# } #NEWLINE# for k in util . get_cls_kwargs ( poolclass ) : #NEWLINE# #INDENT# tk = translate . get ( k , k ) #NEWLINE# if ( tk in kwargs ) : #NEWLINE# #INDENT# pool_args [ k ] = pop_kwarg ( tk ) #NEWLINE# #UNINDENT# #UNINDENT# pool = poolclass ( creator , ** pool_args ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( pool , poollib . _DBProxy ) : #NEWLINE# #INDENT# pool = pool . get_pool ( * cargs , ** cparams ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# pool = pool #NEWLINE# #UNINDENT# #UNINDENT# engineclass = self . engine_cls #NEWLINE# engine_args = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for k in util . get_cls_kwargs ( engineclass ) : #NEWLINE# #INDENT# if ( k in kwargs ) : #NEWLINE# #INDENT# engine_args [ k ] = pop_kwarg ( k ) #NEWLINE# #UNINDENT# #UNINDENT# _initialize = kwargs . pop ( '_initialize' , True ) #NEWLINE# if kwargs : #NEWLINE# #INDENT# raise TypeError ( ( 'Invalid argument(s) %s sent to create_engine(), using configuration %s/%s/%s.  Please check that the keyword arguments are appropriate for this combination of components.' % ( ',' . join ( ( ( "'%s'" % k ) for k in kwargs ) ) , dialect . __class__ . __name__ , pool . __class__ . __name__ , engineclass . __name__ ) ) ) #NEWLINE# #UNINDENT# engine = engineclass ( pool , dialect , u , ** engine_args ) #NEWLINE# if _initialize : #NEWLINE# #INDENT# do_on_connect = dialect . on_connect ( ) #NEWLINE# if do_on_connect : #NEWLINE# #INDENT# def on_connect( dbapi_connection , connection_record ) : #NEWLINE# #INDENT# conn = getattr ( dbapi_connection , '_sqla_unwrap' , dbapi_connection ) #NEWLINE# if ( conn is None ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# do_on_connect ( conn ) #NEWLINE# #UNINDENT# event . listen ( pool , 'first_connect' , on_connect ) #NEWLINE# event . listen ( pool , 'connect' , on_connect ) #NEWLINE# #UNINDENT# def first_connect( dbapi_connection , connection_record ) : #NEWLINE# #INDENT# c = base . Connection ( engine , connection = dbapi_connection , _has_events = False ) #NEWLINE# c . _execution_options = util . immutabledict ( ) #NEWLINE# dialect . initialize ( c ) #NEWLINE# #UNINDENT# event . listen ( pool , 'first_connect' , first_connect , once = True ) #NEWLINE# #UNINDENT# return engine