From 4908cc8987d850a2836fe8f6d79a4d5414518747 Mon Sep 17 00:00:00 2001 From: Cinabre Date: Wed, 16 Dec 2020 20:52:45 +0100 Subject: [PATCH] =?UTF-8?q?Creation=20du=20fichier=20+=20fonction=20get=5F?= =?UTF-8?q?username=20=C3=A0=20partir=20de=20l'id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 database.py diff --git a/database.py b/database.py new file mode 100644 index 0000000..5123ab8 --- /dev/null +++ b/database.py @@ -0,0 +1,9 @@ +import sqlite3, sys +conn = sqlite3.connect('database.db') +cursor = conn.cursor() + + +def get_username(id): + cursor.execute("SELECT username FROM users WHERE id = '%s';" % id) + rows = cursor.fetchall() + return rows[0][0]