55
66from ..collection .Collection import Collection
77from ..config import load_config
8+ from ..connections import ConnectionResolver
89from ..exceptions import (
910 HTTP404 ,
1011 ConnectionNotRegistered ,
@@ -107,8 +108,8 @@ def __init__(
107108 self .set_action ("select" )
108109
109110 if not self ._connection_details :
110- DB = load_config (config_path = self .config_path ).DB
111- self ._connection_details = DB .get_connection_details ()
111+ resolver = load_config (config_path = self .config_path ).DB
112+ self ._connection_details = resolver .get_connection_details ()
112113
113114 self .on (connection )
114115
@@ -398,8 +399,6 @@ def method(*args, **kwargs):
398399 )
399400
400401 def on (self , connection ):
401- DB = load_config (self .config_path ).DB
402-
403402 if connection == "default" :
404403 self .connection = self ._connection_details .get ("default" )
405404 else :
@@ -413,7 +412,10 @@ def on(self, connection):
413412 self ._connection_driver = self ._connection_details .get (
414413 self .connection
415414 ).get ("driver" )
416- self .connection_class = DB .connection_factory .make (
415+ resolver = ConnectionResolver (
416+ connection_details = self ._connection_details
417+ )
418+ self .connection_class = resolver .connection_factory .make (
417419 self ._connection_driver
418420 )
419421
0 commit comments