44from duckdb_extensions import import_extension
55from packaging .version import Version
66
7+ from deepnote_toolkit .logging import LoggerManager
8+
79_DEEPNOTE_DUCKDB_CONNECTION = None
810_DEFAULT_DUCKDB_SAMPLE_SIZE = 20_000
911
@@ -41,6 +43,7 @@ def _get_duckdb_connection():
4143 duckdb.Connection: A connection to the DuckDB database.
4244 """
4345 global _DEEPNOTE_DUCKDB_CONNECTION
46+ logger = LoggerManager ().get_logger ()
4447
4548 if not _DEEPNOTE_DUCKDB_CONNECTION :
4649 _DEEPNOTE_DUCKDB_CONNECTION = duckdb .connect (
@@ -55,10 +58,15 @@ def _get_duckdb_connection():
5558 # there is also official excel extension, which mentions that Excel support from spatial extension
5659 # may be removed in the future (see: https://duckdb.org/docs/stable/core_extensions/excel)
5760 for extension_name in ["spatial" , "excel" ]:
58- import_extension (
59- name = extension_name , force_install = True , con = _DEEPNOTE_DUCKDB_CONNECTION
60- )
61- _DEEPNOTE_DUCKDB_CONNECTION .load_extension (extension_name )
61+ try :
62+ import_extension (
63+ name = extension_name ,
64+ force_install = True ,
65+ con = _DEEPNOTE_DUCKDB_CONNECTION ,
66+ )
67+ _DEEPNOTE_DUCKDB_CONNECTION .load_extension (extension_name )
68+ except Exception as e :
69+ logger .error (f"Failed to load DuckDB { extension_name } extension: { e } " )
6270
6371 _set_sample_size (_DEEPNOTE_DUCKDB_CONNECTION , _DEFAULT_DUCKDB_SAMPLE_SIZE )
6472
0 commit comments