Revize d6ccc8ca
Přidáno uživatelem David Friesecký před téměř 4 roky(ů)
src/dao/private_key_repository.py | ||
---|---|---|
1 | 1 |
from sqlite3 import Connection, Cursor, Error |
2 |
from typing import List |
|
2 | 3 |
|
3 | 4 |
from src.db_objects.private_key import PrivateKey |
4 | 5 |
from src.constants import * |
... | ... | |
70 | 71 |
else: |
71 | 72 |
return None |
72 | 73 |
|
74 |
def read_all(self): |
|
75 |
""" |
|
76 |
Reads (selects) all private keys. |
|
77 |
|
|
78 |
:return: list of private keys |
|
79 |
""" |
|
80 |
|
|
81 |
try: |
|
82 |
sql = f"SELECT * FROM {TAB_PRIVATE_KEYS}" |
|
83 |
self.cursor.execute(sql) |
|
84 |
private_key_rows = self.cursor.fetchall() |
|
85 |
|
|
86 |
private_keys: List[PrivateKey] = [] |
|
87 |
for private_key_row in private_key_rows: |
|
88 |
private_keys.append(PrivateKey(private_key_row[0], |
|
89 |
private_key_row[1], |
|
90 |
private_key_row[2])) |
|
91 |
except Error as e: |
|
92 |
print(e) |
|
93 |
return None |
|
94 |
|
|
95 |
if len(private_keys) > 0: |
|
96 |
return private_keys |
|
97 |
else: |
|
98 |
return None |
|
99 |
|
|
73 | 100 |
def update(self, private_key_id: int, private_key: PrivateKey) -> bool: |
74 | 101 |
""" |
75 | 102 |
Updates a private key. |
Také k dispozici: Unified diff
Re #8471 - Implemented selection of all private keys