Return new user's id in Database.users.add

This commit is contained in:
jesopo 2018-11-13 11:19:43 +00:00
parent 8fc7a7652a
commit 66643a1bd8
2 changed files with 4 additions and 1 deletions

View file

@ -36,6 +36,8 @@ class Channels(Table):
self.database.execute("""INSERT OR IGNORE INTO channels self.database.execute("""INSERT OR IGNORE INTO channels
(server_id, name) VALUES (?, ?)""", (server_id, name) VALUES (?, ?)""",
[server_id, name.lower()]) [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): def delete(self, channel_id: int):
self.database.execute("DELETE FROM channels WHERE channel_id=?", self.database.execute("DELETE FROM channels WHERE channel_id=?",
[channel_id]) [channel_id])

View file

@ -16,5 +16,6 @@ def add_server(database: Database.Database):
realname = input("realname: ") realname = input("realname: ")
bindhost = input("bindhost?: ") bindhost = input("bindhost?: ")
admin = input("admin nickname: ") 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) bindhost, nickname, username, realname)