Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/examples/quickstart/quickstart_6.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions docs/examples/usage/usage_configuration_2.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 6 additions & 2 deletions docs/examples/usage/usage_configuration_7.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
9 changes: 7 additions & 2 deletions docs/examples/usage/usage_drivers_and_querying_10.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@

from pathlib import Path

import pytest

__all__ = ("test_example_10_duckdb_config",)

pytestmark = pytest.mark.xdist_group("duckdb")


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
Expand All @@ -16,7 +20,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, "read_only": False})

with spec.provide_session(config) as session:
# Create table from Parquet
Expand Down
7 changes: 5 additions & 2 deletions docs/examples/usage/usage_drivers_and_querying_6.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 6 additions & 2 deletions docs/examples/usage/usage_drivers_and_querying_8.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down