Skip to content

Commit 02ed692

Browse files
committed
Add testcases using sqlalchemy engine and connection
1 parent 648240b commit 02ed692

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/test_io.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
)
4444
from pandas._testing import ensure_clean
4545
import pytest
46+
import sqlalchemy
4647
from typing_extensions import assert_type
4748

4849
from tests import check
@@ -692,6 +693,31 @@ def test_read_sql():
692693
con.close()
693694

694695

696+
def test_read_sql_via_sqlalchemy_connection():
697+
with ensure_clean() as path:
698+
db_uri = "sqlite:///" + path
699+
engine = sqlalchemy.create_engine(db_uri)
700+
701+
with engine.connect() as conn:
702+
check(assert_type(DF.to_sql("test", con=conn), Union[int, None]), int)
703+
check(
704+
assert_type(read_sql("select * from test", con=conn), DataFrame),
705+
DataFrame,
706+
)
707+
708+
709+
def test_read_sql_via_sqlalchemy_engine():
710+
with ensure_clean() as path:
711+
db_uri = "sqlite:///" + path
712+
engine = sqlalchemy.create_engine(db_uri)
713+
714+
check(assert_type(DF.to_sql("test", con=engine), Union[int, None]), int)
715+
check(
716+
assert_type(read_sql("select * from test", con=engine), DataFrame),
717+
DataFrame,
718+
)
719+
720+
695721
def test_read_sql_generator():
696722
with ensure_clean() as path:
697723
con = sqlite3.connect(path)

0 commit comments

Comments
 (0)