From 112ed11d334395230d0cc871bec3c4a37111a3fc Mon Sep 17 00:00:00 2001 From: Evgeny Skvortsov <71790359+EvgSkv@users.noreply.github.com> Date: Sun, 13 Oct 2024 17:21:37 -0500 Subject: [PATCH] Make DuckDB run from RunQueryPandas. --- common/logica_lib.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/logica_lib.py b/common/logica_lib.py index a494d86..ef50b00 100644 --- a/common/logica_lib.py +++ b/common/logica_lib.py @@ -140,6 +140,9 @@ def RunQueryPandas(sql, engine, connection=None): import pandas if connection is None and engine == 'sqlite': connection = sqlite3_logica.SqliteConnect() + if connection is None and engine == 'duckdb': + import duckdb + connection = duckdb.connect() if connection is None: assert False, 'Connection is required for engines other than SQLite.' if engine == 'bigquery': @@ -152,6 +155,9 @@ def RunQueryPandas(sql, engine, connection=None): rows, columns=[d[0] for d in cursor.description]) df = df.applymap(psql_logica.DigestPsqlType) return df + elif engine == 'duckdb': + import duckdb + return connection.sql(sql).df() elif engine == 'sqlite': statements = parse.SplitRaw(sql, ';')[:-1] if len(statements) > 1: