Skip to content

Commit

Permalink
set the busy_timeout pragma
Browse files Browse the repository at this point in the history
  • Loading branch information
imryche committed Jan 20, 2025
1 parent ae646e4 commit b9f991f
Show file tree
Hide file tree
Showing 6 changed files with 477 additions and 4 deletions.
2 changes: 1 addition & 1 deletion litequery/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from litequery.core import setup

__version__ = "0.5.3"
__version__ = "0.5.4"
__all__ = ["setup"]
1 change: 1 addition & 0 deletions litequery/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class LitequeryBase:
("mmap_size", 134217728), # 128 Mb
("journal_size_limit", 67108864), # 64 Mb
("cache_size", 2000),
("busy_timeout", 5000),
]

def __init__(self, database, queries):
Expand Down
7 changes: 7 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[env]
_.file = ".env"
_.python.venv = {path = ".venv", create = true}

[tools]
python = "3.11"
uv = "latest"
12 changes: 11 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "litequery"
version = "0.5.3"
version = "0.5.4"
authors = [{ name = "Dima Charnyshou", email = "[email protected]" }]
description = "A handy way to interact with an SQLite database from Python"
readme = "README.md"
Expand All @@ -14,6 +14,11 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = [
"aiosqlite",
"pytest",
"pytest-asyncio",
]

[project.urls]
Homepage = "https://github.com/imryche/litequery"
Expand All @@ -29,3 +34,8 @@ extend-ignore = ["UP007"]

[tool.ruff.lint]
extend-select = ["I", "UP", "E501", "ASYNC"]

[dependency-groups]
dev = [
"ipdb>=0.13.13",
]
7 changes: 5 additions & 2 deletions tests/test_core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import sqlite3
from dataclasses import fields
from datetime import datetime

import pytest
Expand Down Expand Up @@ -233,12 +234,13 @@ async def test_pragmas_configured_async(lq_async):
("mmap_size", 134217728), # 128 Mb
("journal_size_limit", 67108864), # 64 Mb
("cache_size", 2000),
("busy_timeout", 5000),
]
conn = await lq_async.get_connection()
for pragma, expected_value in expected_pragmas:
async with conn.execute(f"pragma {pragma}") as cursor:
result = await cursor.fetchone()
assert getattr(result, pragma) == expected_value
assert getattr(result, fields(result)[0].name, None) == expected_value


def test_pragmas_configured_sync(lq_sync):
Expand All @@ -249,8 +251,9 @@ def test_pragmas_configured_sync(lq_sync):
("mmap_size", 134217728), # 128 Mb
("journal_size_limit", 67108864), # 64 Mb
("cache_size", 2000),
("busy_timeout", 5000),
]
conn = lq_sync.get_connection()
for pragma, expected_value in expected_pragmas:
result = conn.execute(f"pragma {pragma}").fetchone()
assert getattr(result, pragma) == expected_value
assert getattr(result, fields(result)[0].name, None) == expected_value
Loading

0 comments on commit b9f991f

Please sign in to comment.