Now test-passing!

This commit is contained in:
hhh
2024-03-17 15:54:31 +02:00
parent b0523e141e
commit a0db44f945
3 changed files with 161 additions and 114 deletions

View File

@@ -3,10 +3,10 @@ Defines the Datalite decorator that can be used to convert a dataclass to
a class bound to an sqlite3 database.
"""
from dataclasses import asdict, fields
from sqlite3.dbapi2 import IntegrityError
from typing import Callable, Dict, Optional
import aiosqlite
from aiosqlite import IntegrityError
from .commons import _create_table, _tweaked_create_table, _tweaked_dump, type_table
from .constraints import ConstraintFailedError
@@ -36,6 +36,9 @@ async def _create_entry(self) -> None:
await con.commit()
except IntegrityError:
raise ConstraintFailedError("A constraint has failed.")
finally:
await cur.close()
await con.close()
async def _tweaked_create_entry(self) -> None:
@@ -55,6 +58,9 @@ async def _tweaked_create_entry(self) -> None:
await con.commit()
except IntegrityError:
raise ConstraintFailedError("A constraint has failed.")
finally:
await cur.close()
await con.close()
async def _update_entry(self) -> None: