Skip to content

Commit 4039cc7

Browse files
authored
fix: cannot set allowed_directories when external access is disabled (#1064)
1 parent 92d81b6 commit 4039cc7

File tree

1 file changed

+5
-0
lines changed
  • insights/insights/doctype/insights_data_source_v3/connectors

1 file changed

+5
-0
lines changed

insights/insights/doctype/insights_data_source_v3/connectors/duckdb.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# For license information, please see license.txt
33

44
import os
5+
from contextlib import suppress
56
from urllib.parse import urlparse
67

78
import frappe
@@ -32,6 +33,10 @@ def get_local_duckdb_connection(db_name, read_only=True, allowed_dir=None):
3233

3334
if allowed_dir:
3435
escaped_dir = allowed_dir.replace("'", "''")
36+
# Some environments start with external access already disabled.
37+
# Best effort: try enabling it first, then configure directory allowlist.
38+
with suppress(Exception):
39+
db.raw_sql("SET enable_external_access = true")
3540
db.raw_sql(f"SET allowed_directories = ['{escaped_dir}']")
3641

3742
db.raw_sql("SET enable_external_access = false")

0 commit comments

Comments
 (0)