Advertisement
Guest User

Error with get_case()

a guest
Dec 12th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.75 KB | None | 0 0
  1. import sqlite3
  2.  
  3. class Storage:
  4.     connection = sqlite3.connect('./storage.db')
  5.     cursor = connection.cursor()
  6.     bounds = [0, 50, 100, 250, 500, 1000, 2500, 5000, 10000, 25000, 50000, 100000, 250000, 500000, 1000000]
  7.  
  8.     def __init__(self):
  9.         Storage.cursor.execute( ''' CREATE TABLE Levels(Member TEXT PRIMARY KEY, XP TEXT) ''' )
  10.         Storage.cursor.execute( ''' CREATE TABLE Modmail(Docket TEXT PRIMARY KEY, Report TEXT) ''' )
  11.         Storage.connection.commit()
  12.  
  13.     def get_level(self, xp: int):
  14.         for level in range(len(Storage.bounds)):
  15.             if xp < Storage.bounds[level+1] and xp >= Storage.bounds[level]:
  16.                 return level+1
  17.             else:
  18.                 pass
  19.  
  20.     def get_xp(self, cls, memberID: str):
  21.         results = Storage.cursor.execute( ''' SELECT XP FROM Levels WHERE Member = ? ''', (memberID) )
  22.         return result[0]
  23.  
  24.     def add_xp(self, cls, memberID: str, gain: int):
  25.         current = Storage.cursor.execute( ''' SELECT XP FROM Levels WHERE Member = ? ''', (memberID) )
  26.         new = int(current) + gain
  27.         Storage.cursor.execute( ''' UPDATE Levels SET XP = ? WHERE Member = ? ''', (new, memberID) )
  28.         Storage.connection.commit()
  29.  
  30.     def new_case(docket: str, report: str):
  31.         Storage.cursor.execute( ''' INSERT INTO Modmail(Docket, Report) VALUES (?, ?) ''', (docket, report) )
  32.         Storage.connection.commit()
  33.  
  34.     def get_case(param: str):
  35.         results = {}
  36.         search = Storage.cursor.execute( '''SELECT Report FROM Modmail WHERE Docket LIKE '%?%' ''', (param) )
  37.         for report in search:
  38.             results[report] = cursor.execute( '''SELECT Docket FROM Modmail WHERE Report = ?''', (report) )
  39.         return results
  40.  
  41. Storage.get_case("35434")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement