@@ -267,6 +267,7 @@ class BaseDuckDBConnectionConfig(ConnectionConfig):
267267 extensions: A list of autoloadable extensions to load.
268268 connector_config: A dictionary of configuration to pass into the duckdb connector.
269269 secrets: A list of dictionaries used to generate DuckDB secrets for authenticating with external services (e.g. S3).
270+ file_systems: A list of dictionaries used to register `fsspec` filesystems to the DuckDB cursor.
270271 concurrent_tasks: The maximum number of tasks that can use this connection concurrently.
271272 register_comments: Whether or not to register model comments with the SQL engine.
272273 pre_ping: Whether or not to pre-ping the connection before starting a new transaction to ensure it is still alive.
@@ -278,6 +279,7 @@ class BaseDuckDBConnectionConfig(ConnectionConfig):
278279 extensions : t .List [t .Union [str , t .Dict [str , t .Any ]]] = []
279280 connector_config : t .Dict [str , t .Any ] = {}
280281 secrets : t .List [t .Dict [str , t .Any ]] = []
282+ file_systems : t .List [t .Dict [str , t .Any ]] = []
281283
282284 concurrent_tasks : int = 1
283285 register_comments : bool = True
@@ -372,6 +374,15 @@ def init(cursor: duckdb.DuckDBPyConnection) -> None:
372374 except Exception as e :
373375 raise ConfigError (f"Failed to create secret: { e } " )
374376
377+ if self .file_systems :
378+ from fsspec import filesystem # type: ignore
379+
380+ for file_system in self .file_systems :
381+ protocol = file_system .pop ("protocol" )
382+ storage_options = file_system .pop ("storage_options" )
383+ fs = filesystem (protocol , ** storage_options )
384+ cursor .register_filesystem (fs )
385+
375386 for i , (alias , path_options ) in enumerate (
376387 (getattr (self , "catalogs" , None ) or {}).items ()
377388 ):
@@ -383,24 +394,6 @@ def init(cursor: duckdb.DuckDBPyConnection) -> None:
383394 try :
384395 if isinstance (path_options , DuckDBAttachOptions ):
385396 query = path_options .to_sql (alias )
386-
387- if path_options .data_path .split (":" )[0 ] == "abfs" :
388-
389- if path_options .azure_account_name is None or path_options .azure_account_host is None :
390- raise ValueError ("azure_account_name and azure_account_host must be set when using abfs protocol" )
391-
392-
393- storage_options = {
394- "account_name" : path_options .azure_account_name ,
395- "account_host" : path_options .azure_account_host ,
396- "anon" :False ,
397- }
398- from fsspec import filesystem
399-
400- fs = filesystem ("abfs" , ** storage_options )
401- cursor .register_filesystem (fs )
402- cursor .commit ()
403-
404397 else :
405398 query = f"ATTACH IF NOT EXISTS '{ path_options } '"
406399 if not path_options .startswith ("md:" ):
0 commit comments