Skip to content

Commit

Permalink
use user setting instead of no_cache
Browse files Browse the repository at this point in the history
  • Loading branch information
guenp committed Jul 27, 2024
1 parent 4f83880 commit 68f163d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions duckdb_engine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,9 @@ def initialize(self, connection: "Connection") -> None:
def create_connect_args(self, url: URL) -> Tuple[tuple, dict]:
opts = url.translate_connect_args(database="database")
opts["url_config"] = dict(url.query)
if opts["url_config"].pop("no_cache", False):
opts["database"] += f"?no_cache={uuid.uuid4()}"
user = opts["url_config"].pop("user", None)
if user is not None:
opts["database"] += f"?user={user}"
return (), opts

@classmethod
Expand Down
4 changes: 2 additions & 2 deletions duckdb_engine/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,8 @@ def test_with_cache(tmp_path: Path) -> None:

def test_no_cache(tmp_path: Path) -> None:
tmp_db_path = str(tmp_path / "db_no_cache")
engine1 = create_engine(f"duckdb:///{tmp_db_path}?threads=1")
engine2 = create_engine(f"duckdb:///{tmp_db_path}?threads=2&no_cache=true")
engine1 = create_engine(f"duckdb:///{tmp_db_path}?threads=1&user=1")
engine2 = create_engine(f"duckdb:///{tmp_db_path}?threads=2&user=2")
with engine1.connect() as conn1:
with engine2.connect() as conn2:
res1 = conn1.execute(text("select value from duckdb_settings() where name = 'threads'")).fetchall()
Expand Down

0 comments on commit 68f163d

Please sign in to comment.