Revize a0602bad
Přidáno uživatelem David Friesecký před asi 4 roky(ů)
src/impl/db_manager.py | ||
---|---|---|
10 | 10 |
|
11 | 11 |
@staticmethod |
12 | 12 |
def create(sql: str, values: List, usages: Dict[int, bool] = None) -> bool: |
13 |
""" |
|
14 |
Creates an item in database |
|
15 |
|
|
16 |
:param sql: SQL query for creation (parameter values are replaced by question mark) |
|
17 |
:param values: list of parameter values |
|
18 |
:param usages: dictionary of usages IDs which certificate use |
|
19 |
Dictionary[Integer, Boolean] |
|
20 |
- Key = ID (CA_ID=1, SSL_ID=2, SIGNATURE_ID=3, AUTHENTICATION_ID=4) |
|
21 |
- Value = used=True/unused=False |
|
22 |
|
|
23 |
:return: the result of whether the creation was successful |
|
24 |
""" |
|
25 |
|
|
13 | 26 |
conn = None |
14 | 27 |
try: |
15 | 28 |
conn = sqlite3.connect(DATABASE_FILE) |
... | ... | |
35 | 48 |
|
36 | 49 |
@staticmethod |
37 | 50 |
def read(sql: str, item_id: int = None): |
51 |
""" |
|
52 |
Reads (selecs) an item or items from database |
|
53 |
|
|
54 |
:param sql: SQL query for selection (parameter values are replaced by question mark) |
|
55 |
:param item_id: ID of specific item |
|
56 |
|
|
57 |
:return: list of rows selected from database |
|
58 |
""" |
|
59 |
|
|
38 | 60 |
conn = None |
39 | 61 |
try: |
40 | 62 |
conn = sqlite3.connect(DATABASE_FILE) |
... | ... | |
57 | 79 |
|
58 | 80 |
@staticmethod |
59 | 81 |
def update(sql: str, item_id: int, values: List, usages: Dict[int, bool] = None) -> bool: |
82 |
""" |
|
83 |
Updates an item in database |
|
84 |
|
|
85 |
:param sql: SQL query for creation (parameter values are replaced by question mark) |
|
86 |
:param item_id: ID of specific item |
|
87 |
:param values: list of parameter values |
|
88 |
:param usages: dictionary of usages IDs which certificate use |
|
89 |
Dictionary[Integer, Boolean] |
|
90 |
- Key = ID (CA_ID=1, SSL_ID=2, SIGNATURE_ID=3, AUTHENTICATION_ID=4) |
|
91 |
- Value = used=True/unused=False |
|
92 |
|
|
93 |
:return: the result of whether the updation was successful |
|
94 |
""" |
|
95 |
|
|
60 | 96 |
conn = None |
61 | 97 |
try: |
62 | 98 |
values.append(item_id) |
... | ... | |
88 | 124 |
|
89 | 125 |
@staticmethod |
90 | 126 |
def delete(sql: str, item_id: int, delete_usages: bool) -> bool: |
127 |
""" |
|
128 |
Deletes an item from database |
|
129 |
|
|
130 |
:param sql: SQL query for selection (parameter values are replaced by question mark) |
|
131 |
:param item_id: ID of specific item |
|
132 |
:param delete_usages: flag specifying whether to erase rows with specific id |
|
133 |
from the table of usages (CertificateUsages) |
|
134 |
|
|
135 |
:return: the result of whether the deletion was successful |
|
136 |
""" |
|
137 |
|
|
91 | 138 |
conn = None |
92 | 139 |
try: |
93 | 140 |
conn = sqlite3.connect(DATABASE_FILE) |
Také k dispozici: Unified diff
Re #8471 - Added comments for CRUD functions