From 66643a1bd82d0bc1d7e339d58314e6b23e2aa251 Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 13 Nov 2018 11:19:43 +0000 Subject: [PATCH] Return new user's id in Database.users.add --- src/Database.py | 2 ++ src/utils/cli.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Database.py b/src/Database.py index 2dcd6471..3a5b498d 100644 --- a/src/Database.py +++ b/src/Database.py @@ -36,6 +36,8 @@ class Channels(Table): self.database.execute("""INSERT OR IGNORE INTO channels (server_id, name) VALUES (?, ?)""", [server_id, name.lower()]) + return self.database.execute_fetchone( + "SELECT user_id FROM users ORDER BY user_id DESC LIMIT 1")[0] def delete(self, channel_id: int): self.database.execute("DELETE FROM channels WHERE channel_id=?", [channel_id]) diff --git a/src/utils/cli.py b/src/utils/cli.py index a7ab33c9..79132056 100644 --- a/src/utils/cli.py +++ b/src/utils/cli.py @@ -16,5 +16,6 @@ def add_server(database: Database.Database): realname = input("realname: ") bindhost = input("bindhost?: ") admin = input("admin nickname: ") - id = database.servers.add(alias, hostname, port, password, ipv4, tls, + + server_id = database.servers.add(alias, hostname, port, password, ipv4, tls, bindhost, nickname, username, realname)