Initial commit
This commit is contained in:
commit
ea3d2f6c43
BIN
example.db
Normal file
BIN
example.db
Normal file
Binary file not shown.
35
main.py
Normal file
35
main.py
Normal file
@ -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()
|
||||
Loading…
x
Reference in New Issue
Block a user