From 7ab4fda354986715ec55eec2d20edbcc4c3db65b Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Tue, 13 Feb 2024 14:41:38 -0500 Subject: [PATCH] fix(postgres): pass through additional kwargs in pguri --- ibis/backends/postgres/__init__.py | 4 ++++ ibis/backends/postgres/tests/test_client.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/ibis/backends/postgres/__init__.py b/ibis/backends/postgres/__init__.py index 0c546f00985f..49bc4c519863 100644 --- a/ibis/backends/postgres/__init__.py +++ b/ibis/backends/postgres/__init__.py @@ -207,6 +207,7 @@ def do_connect( port: int = 5432, database: str | None = None, schema: str | None = None, + **kwargs: Any, ) -> None: """Create an Ibis client connected to PostgreSQL database. @@ -224,6 +225,8 @@ def do_connect( Database to connect to schema PostgreSQL schema to use. If `None`, use the default `search_path`. + kwargs + Additional keyword arguments to pass to the backend client connection. Examples -------- @@ -265,6 +268,7 @@ def do_connect( password=password, database=database, options=(f"-csearch_path={schema}" * (schema is not None)) or None, + **kwargs, ) with self.begin() as cur: diff --git a/ibis/backends/postgres/tests/test_client.py b/ibis/backends/postgres/tests/test_client.py index 03601d77efe3..dcfa269c370d 100644 --- a/ibis/backends/postgres/tests/test_client.py +++ b/ibis/backends/postgres/tests/test_client.py @@ -238,3 +238,10 @@ def test_timezone_from_column(contz, snapshot): ) tm.assert_frame_equal(result, expected) snapshot.assert_match(ibis.to_sql(case), "out.sql") + + +def test_kwargs_passthrough_in_connect(): + con = ibis.connect( + "postgresql://postgres:postgres@localhost/ibis_testing?sslmode=allow" + ) + assert con.current_database == "ibis_testing"