Skip to content

Commit

Permalink
fix(duckdb): explicitly set timezone to UTC on connection
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Feb 15, 2023
1 parent 38d2276 commit 6ae4a06
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions ibis/backends/duckdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,18 @@ def do_connect(
Path(temp_directory).mkdir(parents=True, exist_ok=True)
config["temp_directory"] = str(temp_directory)

super().do_connect(
sa.create_engine(
f"duckdb:///{database}",
connect_args=dict(read_only=read_only, config=config),
poolclass=sa.pool.SingletonThreadPool if in_memory else None,
)
engine = sa.create_engine(
f"duckdb:///{database}",
connect_args=dict(read_only=read_only, config=config),
poolclass=sa.pool.SingletonThreadPool if in_memory else None,
)

@sa.event.listens_for(engine, "connect")
def set_time_zone(dbapi_connection, connection_record):
dbapi_connection.execute("SET TimeZone = 'UTC'")

super().do_connect(engine)

self._meta = sa.MetaData()
self._extensions = set()

Expand Down

0 comments on commit 6ae4a06

Please sign in to comment.