@@ -16,10 +16,10 @@ def __init__(self) -> None:
16
16
# we can use any connection string here
17
17
super ().__init__ ("sqlite://:memory:" , path .join (path .dirname (__file__ ), "migrations" ))
18
18
19
- @BaseDb .with_cursor
20
19
def select_all_basic (self , cursor : Cursor ) -> List [Basic ]:
21
- cursor .execute ("SELECT * FROM basic" )
22
- return [Basic (* x ) for x in cursor .fetchall ()]
20
+ with self .get_cursor () as cursor :
21
+ cursor .execute ("SELECT * FROM basic" )
22
+ return [Basic (* x ) for x in cursor .fetchall ()]
23
23
24
24
def select_basic_by_id (self , basic_id : int ) -> Optional [Basic ]:
25
25
with self .get_cursor () as cursor :
@@ -37,13 +37,14 @@ def insert_basic(self, basic: Basic) -> None:
37
37
basic .name ,
38
38
))
39
39
40
- @BaseDb .with_cursor
41
40
def update_basic (self , basic : Basic , cursor : Cursor ) -> None :
42
- cursor .execute ("UPDATE basic SET name = ? WHERE id = ?" , (
43
- basic .name ,
44
- basic .id ,
45
- ))
41
+ with self .get_cursor () as cursor :
42
+ cursor .execute ("UPDATE basic SET name = ? WHERE id = ?" , (
43
+ basic .name ,
44
+ basic .id ,
45
+ ))
46
46
47
- @BaseDb .with_cursor
48
47
def delete_basic_by_id (self , basic_id : int , cursor : Connection ) -> None :
49
- cursor .execute ("DELETE FROM basic WHERE id = ?" , (basic_id ,))
48
+ with self .get_cursor () as cursor :
49
+ cursor .execute ("DELETE FROM basic WHERE id = ?" , (basic_id ,))
50
+
0 commit comments