lidavidm commented on code in PR #3537:
URL: https://github.com/apache/arrow-adbc/pull/3537#discussion_r2409519558
##########
python/adbc_driver_manager/tests/test_dbapi.py:
##########
@@ -555,3 +555,47 @@ def test_driver_path():
):
with dbapi.connect(driver=pathlib.Path("/tmp/thisdriverdoesnotexist")):
pass
+
+
[email protected]
+def test_connect(tmp_path: pathlib.Path, monkeypatch) -> None:
+ with dbapi.connect(driver="adbc_driver_sqlite") as conn:
+ with conn.cursor() as cur:
+ cur.execute("SELECT 1")
+ assert cur.fetchone() == (1,)
+
+ # https://github.com/apache/arrow-adbc/issues/3517: allow positional
+ # argument
+ with dbapi.connect("adbc_driver_sqlite") as conn:
+ with conn.cursor() as cur:
+ cur.execute("SELECT 1")
+ assert cur.fetchone() == (1,)
+
+ # https://github.com/apache/arrow-adbc/issues/3517: allow URI argument
+ db = tmp_path / "test.db"
+ with dbapi.connect("adbc_driver_sqlite", db.as_uri()) as conn:
+ with conn.cursor() as cur:
+ cur.execute("CREATE TABLE foo (a)")
+ cur.execute("INSERT INTO foo VALUES (1)")
+ conn.commit()
+
+ with dbapi.connect(driver="adbc_driver_sqlite", uri=db.as_uri()) as conn:
+ with conn.cursor() as cur:
+ cur.execute("SELECT * FROM foo")
+ assert cur.fetchone() == (1,)
+
+ monkeypatch.setenv("ADBC_DRIVER_PATH", tmp_path)
+ with (tmp_path / "sqlite.toml").open("w") as f:
+ f.write(
+ """
+[Driver]
+shared = "adbc_driver_sqlite"
+ """
+ )
+ # sqlite actually treats this as a filename (and also removes the
+ # slashes), but for the purposes of testing the driver name inference it
+ # should be fine
+ with dbapi.connect("sqlite://") as conn:
+ with conn.cursor() as cur:
+ cur.execute("SELECT 1")
+ assert cur.fetchone() == (1,)
Review Comment:
It appears Windows doesn't appreciate this. I think I'll just simplify the
test instead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]