Skip to content

Commit 160c9a1

Browse files
committed
Merge branch 'main' into 171_usage_cli
2 parents c8ac811 + 93fbb4b commit 160c9a1

File tree

6 files changed

+34
-10
lines changed

6 files changed

+34
-10
lines changed

docs/examples/quickstart/quickstart_6.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
from pathlib import Path
55

6+
import pytest
7+
8+
pytestmark = pytest.mark.xdist_group("duckdb")
9+
610

711
def test_quickstart_6(tmp_path: Path) -> None:
812
# start-example

docs/examples/usage/usage_configuration_2.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
__all__ = ("test_sqlite_config_setup",)
22

33

4-
def test_sqlite_config_setup() -> None:
4+
from pathlib import Path
5+
6+
7+
def test_sqlite_config_setup(tmp_path: Path) -> None:
58

69
# start-example
710
from sqlspec.adapters.sqlite import SqliteConfig
811

12+
database_file = tmp_path / "myapp.db"
913
config = SqliteConfig(
1014
pool_config={
11-
"database": "myapp.db", # Database file path
15+
"database": database_file.name, # Database file path
1216
"timeout": 5.0, # Lock timeout in seconds
1317
"check_same_thread": False, # Allow multi-thread access
1418
"cached_statements": 100, # Statement cache size
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
__all__ = ("test_duckdb_config_setup",)
22

33

4-
def test_duckdb_config_setup() -> None:
4+
from pathlib import Path
5+
6+
7+
def test_duckdb_config_setup(tmp_path: Path) -> None:
58

69
# start-example
710
from sqlspec.adapters.duckdb import DuckDBConfig
@@ -10,5 +13,6 @@ def test_duckdb_config_setup() -> None:
1013
# end-example
1114
assert in_memory_config.pool_config.get("database") == ":memory:shared_db"
1215

13-
persistent_config = DuckDBConfig(pool_config={"database": "analytics.duckdb", "read_only": False})
16+
database_file = tmp_path / "analytics.duckdb"
17+
persistent_config = DuckDBConfig(pool_config={"database": database_file.name, "read_only": False})
1418
assert persistent_config.pool_config["read_only"] is False

docs/examples/usage/usage_drivers_and_querying_10.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33

44
from pathlib import Path
55

6+
import pytest
7+
68
__all__ = ("test_example_10_duckdb_config",)
79

10+
pytestmark = pytest.mark.xdist_group("duckdb")
11+
812

9-
def test_example_10_duckdb_config() -> None:
13+
def test_example_10_duckdb_config(tmp_path: Path) -> None:
1014
# start-example
1115
from sqlspec import SQLSpec
1216
from sqlspec.adapters.duckdb import DuckDBConfig
@@ -16,7 +20,8 @@ def test_example_10_duckdb_config() -> None:
1620
config = DuckDBConfig()
1721

1822
# Persistent
19-
config = DuckDBConfig(pool_config={"database": "analytics.duckdb"})
23+
database_file = tmp_path / "analytics.duckdb"
24+
config = DuckDBConfig(pool_config={"database": database_file.name, "read_only": False})
2025

2126
with spec.provide_session(config) as session:
2227
# Create table from Parquet

docs/examples/usage/usage_drivers_and_querying_6.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
# Test module converted from docs example - code-block 6
22
"""Minimal smoke test for drivers_and_querying example 6."""
33

4+
from pathlib import Path
5+
46
from sqlspec import SQLSpec
57

68
__all__ = ("test_example_6_sqlite_config",)
79

810

9-
def test_example_6_sqlite_config() -> None:
11+
def test_example_6_sqlite_config(tmp_path: Path) -> None:
1012
# start-example
1113
from sqlspec.adapters.sqlite import SqliteConfig
1214

1315
spec = SQLSpec()
1416

15-
config = SqliteConfig(pool_config={"database": "myapp.db", "timeout": 5.0, "check_same_thread": False})
17+
database_file = tmp_path / "myapp.db"
18+
config = SqliteConfig(pool_config={"database": database_file.name, "timeout": 5.0, "check_same_thread": False})
1619

1720
with spec.provide_session(config) as session:
1821
# Create table

docs/examples/usage/usage_drivers_and_querying_8.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
__all__ = ("test_example_8_aiosqlite_config",)
55

66

7-
async def test_example_8_aiosqlite_config() -> None:
7+
from pathlib import Path
8+
9+
10+
async def test_example_8_aiosqlite_config(tmp_path: Path) -> None:
811
# start-example
912
from sqlspec import SQLSpec
1013
from sqlspec.adapters.aiosqlite import AiosqliteConfig
1114

12-
config = AiosqliteConfig(pool_config={"database": "myapp.db"})
15+
database_file = tmp_path / "myapp.db"
16+
config = AiosqliteConfig(pool_config={"database": database_file})
1317
spec = SQLSpec()
1418

1519
async with spec.provide_session(config) as session:

0 commit comments

Comments
 (0)