summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2025-10-01 00:06:52 -0400
committerJohn Turner <jturner.usa@gmail.com>2025-10-01 00:06:52 -0400
commit5819a29bf653262f9c3c70b1cf56a10526a5fbf0 (patch)
tree4ee713ffe9ab58e232979f506a877aeebfc8b271
parent5261442c30c713120ee84da8bc9114494e7151cf (diff)
downloadpypaste-5819a29bf653262f9c3c70b1cf56a10526a5fbf0.tar.gz
make use of transactions
-rw-r--r--pypaste/server/sqlite/__init__.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/pypaste/server/sqlite/__init__.py b/pypaste/server/sqlite/__init__.py
index 3d5e1b1..5cd00a6 100644
--- a/pypaste/server/sqlite/__init__.py
+++ b/pypaste/server/sqlite/__init__.py
@@ -29,6 +29,8 @@ class Sqlite(Storage):
data = await asyncio.to_thread(compress)
try:
+ await self.connection.execute("begin")
+
await self.connection.execute(
"insert into pastes values(?, ?, ?, ?, ?)",
(
@@ -95,6 +97,8 @@ class Sqlite(Storage):
async def delete(self, key: Key) -> None:
try:
+ await self.connection.execute("begin")
+
await self.connection.execute("delete from pastes where key=?", (key.data,))
await self.connection.execute(