@@ -149,7 +149,7 @@ class BaseDuckDBConnectionConfig(ConnectionConfig):
149149 pre_ping: Whether or not to pre-ping the connection before starting a new transaction to ensure it is still alive.
150150 """
151151
152- extensions : t .List [str ] = []
152+ extensions : t .List [t . Union [ str , t . Dict [ str , t . Any ]] ] = []
153153 connector_config : t .Dict [str , t .Any ] = {}
154154
155155 concurrent_tasks : Literal [1 ] = 1
@@ -174,11 +174,21 @@ def _cursor_init(self) -> t.Optional[t.Callable[[t.Any], None]]:
174174
175175 def init (cursor : duckdb .DuckDBPyConnection ) -> None :
176176 for extension in self .extensions :
177+ extension = extension if isinstance (extension , dict ) else {"name" : extension }
178+
179+ install_command = f"INSTALL { extension ['name' ]} "
180+
181+ if extension .get ("repository" ):
182+ install_command = f"{ install_command } FROM { extension ['repository' ]} "
183+
184+ if extension .get ("force_install" ):
185+ install_command = f"FORCE { install_command } "
186+
177187 try :
178- cursor .execute (f"INSTALL { extension } " )
179- cursor .execute (f"LOAD { extension } " )
188+ cursor .execute (install_command )
189+ cursor .execute (f"LOAD { extension [ 'name' ] } " )
180190 except Exception as e :
181- raise ConfigError (f"Failed to load extension { extension } : { e } " )
191+ raise ConfigError (f"Failed to load extension { extension [ 'name' ] } : { e } " )
182192
183193 for field , setting in self .connector_config .items ():
184194 try :
0 commit comments