Skip to content

Commit

Permalink
Merge pull request #393 from EvgSkv/ti2023
Browse files Browse the repository at this point in the history
Make DuckDB run from RunQueryPandas.
  • Loading branch information
EvgSkv authored Oct 13, 2024
2 parents 7abb7c6 + 112ed11 commit 986c605
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions common/logica_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand All @@ -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:
Expand Down

0 comments on commit 986c605

Please sign in to comment.