compat with older sqlite versions

This commit is contained in:
xenia 2021-06-14 05:35:41 -04:00
parent 325cd3126a
commit 06ce98d358
1 changed files with 2 additions and 5 deletions

View File

@ -70,7 +70,7 @@ class Database:
raise Exception("no more ips left to allocate!")
return next(subnets[0].hosts())
def add_node(self, name: str, public_ip: Optional[ipaddress.IPv4Address], ssh_key: str) -> Node:
def add_node(self, name: str, public_ip: Optional[ipaddress.IPv4Address], ssh_key: str) -> None:
cur = self.conn.cursor()
ip = self._get_free_ip()
@ -81,12 +81,9 @@ class Database:
seckey_bytes = monocypher.crypto_key_exchange_make_key()
seckey = binascii.b2a_base64(seckey_bytes).decode().strip()
cur.execute(
"INSERT INTO nodes (name, public_ip, ip, seckey, ssh_key) VALUES(?, ?, ?, ?, ?) RETURNING id",
"INSERT INTO nodes (name, public_ip, ip, seckey, ssh_key) VALUES(?, ?, ?, ?, ?)",
(name, insert_public_ip, str(ip), seckey, ssh_key))
id: int = cur.fetchone()[0]
cur.close()
self.conn.commit()
return Node(id, name, public_ip, ip, seckey, ssh_key)
def get_node(self, id: int) -> Optional[Node]:
cur = self.conn.cursor()