MCPcopy Index your code
hub / github.com/marimo-team/marimo / test_sql_with_different_engines

Function test_sql_with_different_engines

tests/_sql/test_sql.py:104–126  ·  view source on GitHub ↗

Test sql function with different engines.

(
    sqlite_engine: sa.Engine, duckdb_connection: duckdb.DuckDBPyConnection
)

Source from the content-addressed store, hash-verified

102
103@pytest.mark.skipif(not HAS_SQLALCHEMY, reason="SQLAlchemy not installed")
104def test_sql_with_different_engines(
105 sqlite_engine: sa.Engine, duckdb_connection: duckdb.DuckDBPyConnection
106) -> None:
107 """Test sql function with different engines."""
108 import pandas as pd
109 import polars as pl
110
111 # Test with SQLAlchemy engine
112 result = sql("SELECT * FROM test ORDER BY id", engine=sqlite_engine)
113 assert isinstance(result, (pd.DataFrame, pl.DataFrame))
114 assert len(result) == 3
115
116 # Test with DuckDB connection
117 result = sql("SELECT * FROM test ORDER BY id", engine=duckdb_connection)
118 assert isinstance(result, (pd.DataFrame, pl.DataFrame))
119 assert len(result) == 3
120
121 # Test with default DuckDB
122 # df = pd.DataFrame({"id": [1, 2], "name": ["Alice", "Bob"]})
123 # with patch.dict(globals(), {"df": df}):
124 # result = sql("SELECT * FROM df")
125 # assert isinstance(result, (pd.DataFrame, pl.DataFrame))
126 # assert len(result) == 2
127
128
129def test_sql_with_invalid_engine() -> None:

Callers

nothing calls this directly

Calls 1

sqlFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…