mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-07 17:14:09 +02:00
Merge 4af18681ca into 85b1be10c8
This commit is contained in:
commit
e452229d0a
2 changed files with 12 additions and 0 deletions
|
|
@ -2025,6 +2025,7 @@ class Database:
|
|||
|
||||
def vacuum(self) -> None:
|
||||
"Run a SQLite ``VACUUM`` against the database."
|
||||
self.commit()
|
||||
self.execute("VACUUM;")
|
||||
|
||||
def analyze(self, name: str | None = None) -> None:
|
||||
|
|
|
|||
|
|
@ -1174,6 +1174,17 @@ def test_vacuum(fresh_db):
|
|||
fresh_db.vacuum()
|
||||
|
||||
|
||||
def test_vacuum_commits_open_transaction(fresh_db):
|
||||
fresh_db["data"].insert({"foo": "foo"})
|
||||
fresh_db.begin()
|
||||
fresh_db.execute("insert into data (foo) values ('bar')")
|
||||
|
||||
fresh_db.vacuum()
|
||||
|
||||
assert not fresh_db.conn.in_transaction
|
||||
assert [row["foo"] for row in fresh_db["data"].rows] == ["foo", "bar"]
|
||||
|
||||
|
||||
def test_works_with_pathlib_path(tmpdir):
|
||||
path = pathlib.Path(tmpdir / "test.db")
|
||||
db = Database(path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue