Revize 25053504
Přidáno uživatelem David Friesecký před asi 4 roky(ů)
src/impl/db_manager.py | ||
---|---|---|
7 | 7 |
|
8 | 8 |
class DBManager(IRepository): |
9 | 9 |
|
10 |
def create(self, sql: str, *args) -> bool: |
|
10 |
@staticmethod |
|
11 |
def create(sql: str, *args) -> bool: |
|
11 | 12 |
conn = None |
12 | 13 |
try: |
13 | 14 |
sql: str = args[0] |
... | ... | |
26 | 27 |
conn.close() |
27 | 28 |
return True |
28 | 29 |
|
29 |
def read(self, sql: str, item_id: int = None): |
|
30 |
@staticmethod |
|
31 |
def read(sql: str, item_id: int = None): |
|
30 | 32 |
conn = None |
31 | 33 |
try: |
32 | 34 |
conn = sqlite3.connect(DATABASE_FILE) |
33 | 35 |
c = conn.cursor() |
34 | 36 |
|
35 | 37 |
if item_id is not None: |
36 |
c.execute(sql, item_id) |
|
38 |
list_item_id = [item_id] |
|
39 |
c.execute(sql, list_item_id) |
|
37 | 40 |
else: |
38 | 41 |
c.execute(sql) |
39 | 42 |
|
... | ... | |
47 | 50 |
conn.close() |
48 | 51 |
return records |
49 | 52 |
|
50 |
def update(self, sql: str, *args) -> bool: |
|
53 |
@staticmethod |
|
54 |
def update(sql: str, *args) -> bool: |
|
51 | 55 |
conn = None |
52 | 56 |
try: |
53 | 57 |
conn = sqlite3.connect(DATABASE_FILE) |
... | ... | |
63 | 67 |
conn.close() |
64 | 68 |
return True |
65 | 69 |
|
66 |
def delete(self, sql: str, item_id: int) -> bool: |
|
70 |
@staticmethod |
|
71 |
def delete(sql: str, item_id: int) -> bool: |
|
67 | 72 |
conn = None |
68 | 73 |
try: |
69 | 74 |
conn = sqlite3.connect(DATABASE_FILE) |
Také k dispozici: Unified diff
Re #8471 - Corrected stylistics and warnings