commit ea3d2f6c4379f41bfef1f44243bfc775fb611ec7 Author: Benjamyn Love Date: Tue May 22 02:22:44 2018 +1000 Initial commit diff --git a/example.db b/example.db new file mode 100644 index 0000000..cdd042f Binary files /dev/null and b/example.db differ diff --git a/main.py b/main.py new file mode 100644 index 0000000..4664211 --- /dev/null +++ b/main.py @@ -0,0 +1,35 @@ +import sqlite3 + +conn = sqlite3.connect('example.db') + +cursor = conn.cursor() +try: + cursor.execute('''CREATE TABLE info + (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, date, username, amount, reason)''') +except: + pass + +username = "testuser" +reason1 = "OverQuota" +reason2 = 'spamming' +username2 = "cuntwhokeepdoingthatthang" + +curr_id = None + +cursor.execute('SELECT id FROM info WHERE reason = :reason AND username = :user', {"reason":reason2, "user":username}) +curr_id = cursor.fetchone() +print curr_id +if curr_id == None: + print "First offence, adding to DB" + cursor.execute("INSERT INTO info VALUES(NULL, '22-05-2018', :user, 1, :reason )", {"user":username, "reason":reason2} ) +else: + cursor.execute('SELECT amount FROM info WHERE id = :id', {"id":curr_id[0]}) + res = cursor.fetchone() + print res[0] + cursor.execute('UPDATE info SET amount = :amount WHERE id = :id', {"amount":res[0]+1, "id":curr_id[0]}) + +#cursor.execute("INSERT INTO info VALUES (NULL, '22-05-2018', 'testuser', 1, 'Being a cunt')") + +conn.commit() + +conn.close()