From 55888b8fd22bdb8e1cd970ddff84b889a9218b7b Mon Sep 17 00:00:00 2001 From: euri10 Date: Fri, 21 Nov 2025 10:41:51 +0100 Subject: [PATCH 1/5] fix: use tmp_path to avoid duckdb locks in testing docs --- docs/examples/usage/usage_configuration_7.py | 8 ++++++-- docs/examples/usage/usage_drivers_and_querying_10.py | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/examples/usage/usage_configuration_7.py b/docs/examples/usage/usage_configuration_7.py index 13aed2c0..cb85b76e 100644 --- a/docs/examples/usage/usage_configuration_7.py +++ b/docs/examples/usage/usage_configuration_7.py @@ -1,7 +1,10 @@ __all__ = ("test_duckdb_config_setup",) -def test_duckdb_config_setup() -> None: +from pathlib import Path + + +def test_duckdb_config_setup(tmp_path: Path) -> None: # start-example from sqlspec.adapters.duckdb import DuckDBConfig @@ -10,5 +13,6 @@ def test_duckdb_config_setup() -> None: # end-example assert in_memory_config.pool_config.get("database") == ":memory:shared_db" - persistent_config = DuckDBConfig(pool_config={"database": "analytics.duckdb", "read_only": False}) + database_file = tmp_path / "analytics.duckdb" + persistent_config = DuckDBConfig(pool_config={"database": database_file.name, "read_only": False}) assert persistent_config.pool_config["read_only"] is False diff --git a/docs/examples/usage/usage_drivers_and_querying_10.py b/docs/examples/usage/usage_drivers_and_querying_10.py index b92664ed..f116ad41 100644 --- a/docs/examples/usage/usage_drivers_and_querying_10.py +++ b/docs/examples/usage/usage_drivers_and_querying_10.py @@ -6,7 +6,7 @@ __all__ = ("test_example_10_duckdb_config",) -def test_example_10_duckdb_config() -> None: +def test_example_10_duckdb_config(tmp_path: Path) -> None: # start-example from sqlspec import SQLSpec from sqlspec.adapters.duckdb import DuckDBConfig @@ -16,7 +16,8 @@ def test_example_10_duckdb_config() -> None: config = DuckDBConfig() # Persistent - config = DuckDBConfig(pool_config={"database": "analytics.duckdb"}) + database_file = tmp_path / "analytics.duckdb" + config = DuckDBConfig(pool_config={"database": database_file.name}) with spec.provide_session(config) as session: # Create table from Parquet From 69e68b9a4366a73b9710033c51af76923ee8652f Mon Sep 17 00:00:00 2001 From: euri10 Date: Fri, 21 Nov 2025 10:57:09 +0100 Subject: [PATCH 2/5] is this what caused the lock ? --- docs/examples/usage/usage_drivers_and_querying_10.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/usage/usage_drivers_and_querying_10.py b/docs/examples/usage/usage_drivers_and_querying_10.py index f116ad41..e27ae9c6 100644 --- a/docs/examples/usage/usage_drivers_and_querying_10.py +++ b/docs/examples/usage/usage_drivers_and_querying_10.py @@ -17,7 +17,7 @@ def test_example_10_duckdb_config(tmp_path: Path) -> None: # Persistent database_file = tmp_path / "analytics.duckdb" - config = DuckDBConfig(pool_config={"database": database_file.name}) + config = DuckDBConfig(pool_config={"database": database_file.name, "read_only": False}) with spec.provide_session(config) as session: # Create table from Parquet From c5d6c3f5556bb5238f28493859a1401d0853a7f3 Mon Sep 17 00:00:00 2001 From: euri10 Date: Fri, 21 Nov 2025 11:13:42 +0100 Subject: [PATCH 3/5] more tmp_path --- docs/examples/usage/usage_configuration_2.py | 8 ++++++-- docs/examples/usage/usage_drivers_and_querying_6.py | 7 +++++-- docs/examples/usage/usage_drivers_and_querying_8.py | 8 ++++++-- docs/guides/migrations/hybrid-versioning.md | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/docs/examples/usage/usage_configuration_2.py b/docs/examples/usage/usage_configuration_2.py index c438621a..b2632e30 100644 --- a/docs/examples/usage/usage_configuration_2.py +++ b/docs/examples/usage/usage_configuration_2.py @@ -1,14 +1,18 @@ __all__ = ("test_sqlite_config_setup",) -def test_sqlite_config_setup() -> None: +from pathlib import Path + + +def test_sqlite_config_setup(tmp_path: Path) -> None: # start-example from sqlspec.adapters.sqlite import SqliteConfig + database_file = tmp_path / "myapp.db" config = SqliteConfig( pool_config={ - "database": "myapp.db", # Database file path + "database": database_file.name, # Database file path "timeout": 5.0, # Lock timeout in seconds "check_same_thread": False, # Allow multi-thread access "cached_statements": 100, # Statement cache size diff --git a/docs/examples/usage/usage_drivers_and_querying_6.py b/docs/examples/usage/usage_drivers_and_querying_6.py index aa0e2ea1..18ebaa64 100644 --- a/docs/examples/usage/usage_drivers_and_querying_6.py +++ b/docs/examples/usage/usage_drivers_and_querying_6.py @@ -1,18 +1,21 @@ # Test module converted from docs example - code-block 6 """Minimal smoke test for drivers_and_querying example 6.""" +from pathlib import Path + from sqlspec import SQLSpec __all__ = ("test_example_6_sqlite_config",) -def test_example_6_sqlite_config() -> None: +def test_example_6_sqlite_config(tmp_path: Path) -> None: # start-example from sqlspec.adapters.sqlite import SqliteConfig spec = SQLSpec() - config = SqliteConfig(pool_config={"database": "myapp.db", "timeout": 5.0, "check_same_thread": False}) + database_file = tmp_path / "myapp.db" + config = SqliteConfig(pool_config={"database": database_file.name, "timeout": 5.0, "check_same_thread": False}) with spec.provide_session(config) as session: # Create table diff --git a/docs/examples/usage/usage_drivers_and_querying_8.py b/docs/examples/usage/usage_drivers_and_querying_8.py index 8e86e2fd..64f2c2b7 100644 --- a/docs/examples/usage/usage_drivers_and_querying_8.py +++ b/docs/examples/usage/usage_drivers_and_querying_8.py @@ -4,12 +4,16 @@ __all__ = ("test_example_8_aiosqlite_config",) -async def test_example_8_aiosqlite_config() -> None: +from pathlib import Path + + +async def test_example_8_aiosqlite_config(tmp_path: Path) -> None: # start-example from sqlspec import SQLSpec from sqlspec.adapters.aiosqlite import AiosqliteConfig - config = AiosqliteConfig(pool_config={"database": "myapp.db"}) + database_file = tmp_path / "myapp.db" + config = AiosqliteConfig(pool_config={"database": database_file}) spec = SQLSpec() async with spec.provide_session(config) as session: diff --git a/docs/guides/migrations/hybrid-versioning.md b/docs/guides/migrations/hybrid-versioning.md index 7e617f55..8492acee 100644 --- a/docs/guides/migrations/hybrid-versioning.md +++ b/docs/guides/migrations/hybrid-versioning.md @@ -305,7 +305,7 @@ await config.fix_migrations(dry_run=False, update_database=False, yes=True) from sqlspec.adapters.sqlite import SqliteConfig config = SqliteConfig( - pool_config={"database": "myapp.db"}, + pool_config={"database": " sgmyapp.db"}, migration_config={ "enabled": True, "script_location": "migrations", From 5397d1e0e6bf1cf6503223d22f51de33e04c4f6a Mon Sep 17 00:00:00 2001 From: euri10 Date: Fri, 21 Nov 2025 11:20:16 +0100 Subject: [PATCH 4/5] typo --- docs/guides/migrations/hybrid-versioning.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/migrations/hybrid-versioning.md b/docs/guides/migrations/hybrid-versioning.md index 8492acee..7e617f55 100644 --- a/docs/guides/migrations/hybrid-versioning.md +++ b/docs/guides/migrations/hybrid-versioning.md @@ -305,7 +305,7 @@ await config.fix_migrations(dry_run=False, update_database=False, yes=True) from sqlspec.adapters.sqlite import SqliteConfig config = SqliteConfig( - pool_config={"database": " sgmyapp.db"}, + pool_config={"database": "myapp.db"}, migration_config={ "enabled": True, "script_location": "migrations", From 2bb7a13e8221f5aea86b09697e9025c59fa0f6a1 Mon Sep 17 00:00:00 2001 From: euri10 Date: Fri, 21 Nov 2025 13:12:58 +0100 Subject: [PATCH 5/5] add pytest mark to hopefully group them --- docs/examples/quickstart/quickstart_6.py | 4 ++++ docs/examples/usage/usage_drivers_and_querying_10.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/docs/examples/quickstart/quickstart_6.py b/docs/examples/quickstart/quickstart_6.py index 2fe10f09..1e60cb2c 100644 --- a/docs/examples/quickstart/quickstart_6.py +++ b/docs/examples/quickstart/quickstart_6.py @@ -3,6 +3,10 @@ from pathlib import Path +import pytest + +pytestmark = pytest.mark.xdist_group("duckdb") + def test_quickstart_6(tmp_path: Path) -> None: # start-example diff --git a/docs/examples/usage/usage_drivers_and_querying_10.py b/docs/examples/usage/usage_drivers_and_querying_10.py index e27ae9c6..84e06aef 100644 --- a/docs/examples/usage/usage_drivers_and_querying_10.py +++ b/docs/examples/usage/usage_drivers_and_querying_10.py @@ -3,8 +3,12 @@ from pathlib import Path +import pytest + __all__ = ("test_example_10_duckdb_config",) +pytestmark = pytest.mark.xdist_group("duckdb") + def test_example_10_duckdb_config(tmp_path: Path) -> None: # start-example