File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change 1111
1212
1313def select (catalog_name , key ):
14- with conn :
15- c = conn . cursor ()
14+ c = conn . cursor ()
15+ try :
1616 c .execute (f"SELECT value FROM { catalog_name } WHERE key = ?" , (pickle .dumps (key ),))
1717 if ds := c .fetchone ():
1818 return pickle .loads (ds [0 ])
19+ finally :
20+ c .close ()
1921
2022
2123def select_all (catalog_name ):
22- with conn :
23- c = conn . cursor ()
24+ c = conn . cursor ()
25+ try :
2426 c .execute (f"SELECT key, value FROM { catalog_name } " )
2527 return {pickle .loads (k ): pickle .loads (v ) for k , v in c .fetchall ()}
28+ finally :
29+ c .close ()
2630
2731
2832def catalog_code (catalog_name , key , index = None ):
@@ -63,10 +67,13 @@ def split_at_upper_itr(word: str):
6367
6468
6569def trans (k ):
66- with conn :
67- c = conn . cursor ()
70+ c = conn . cursor ()
71+ try :
6872 c .execute (f"SELECT value FROM Translations WHERE key = ?" , (k ,))
6973 if res := c .fetchone ():
7074 return res [0 ]
71-
7275 return split_at_upper (k )
76+ finally :
77+ c .close ()
78+
79+
You can’t perform that action at this time.
0 commit comments