Revize 805077f5
Přidáno uživatelem David Friesecký před téměř 4 roky(ů)
src/dao/private_key_repository.py | ||
---|---|---|
17 | 17 |
self.connection = connection |
18 | 18 |
self.cursor = cursor |
19 | 19 | |
20 |
def create(self, private_key: PrivateKey) -> bool:
|
|
20 |
def create(self, private_key: PrivateKey): |
|
21 | 21 |
""" |
22 | 22 |
Creates a private key. |
23 | 23 | |
... | ... | |
34 | 34 |
values = [private_key.private_key, |
35 | 35 |
private_key.password] |
36 | 36 |
self.cursor.execute(sql, values) |
37 |
last_id = self.cursor.lastrowid |
|
37 | 38 |
self.connection.commit() |
38 | ||
39 | 39 |
except Error as e: |
40 | 40 |
print(e) |
41 |
return False
|
|
41 |
return None
|
|
42 | 42 | |
43 |
return True
|
|
43 |
return last_id
|
|
44 | 44 | |
45 | 45 |
def read(self, private_key_id: int): |
46 | 46 |
""" |
... | ... | |
65 | 65 |
print(e) |
66 | 66 |
return None |
67 | 67 | |
68 |
return private_key |
|
68 |
if len(private_key_row) > 0: |
|
69 |
return private_key |
|
70 |
else: |
|
71 |
return None |
|
69 | 72 | |
70 | 73 |
def update(self, private_key_id: int, private_key: PrivateKey) -> bool: |
71 | 74 |
""" |
... | ... | |
83 | 86 |
f"{COL_PASSWORD} = ? " |
84 | 87 |
f"WHERE {COL_ID} = ?") |
85 | 88 |
values = [private_key.private_key, |
86 |
private_key.password] |
|
89 |
private_key.password, |
|
90 |
private_key_id] |
|
87 | 91 |
self.cursor.execute(sql, values) |
88 | 92 |
self.connection.commit() |
89 | 93 |
except Error as e: |
Také k dispozici: Unified diff
Re #8471 - Error correction after review