示例#1
0
def creaturedatafetch(creature1, creature2, creature3, creature4):
    creaturearray = []
    query = 'SELECT creatureName, creatureType FROM creatures WHERE creatureID=?'

    cursor.execute(query, [(creature1)])  #runs the query with each creature ID
    creaturearray.append(
        cursor.fetchall())  #puts the result of the query into creaturearray

    cursor.execute(query, [(creature2)])  #repeats
    creaturearray.append(cursor.fetchall())

    cursor.execute(query, [(creature3)])  #repeats
    creaturearray.append(cursor.fetchall())

    cursor.execute(query, [(creature4)])  #repeats
    creaturearray.append(cursor.fetchall())
    return creaturearray
示例#2
0
def existingteamcheck(username):
    query = ('''SELECT userID from userteams WHERE userID = ?
    ''')  #Query created and discussed in write-up
    cursor.execute(query, [(username)])
    teams = cursor.fetchall()  #puts teams fetched into a variable
    if len(teams) > 1:  #Checks how many teams fetched. Allows 2 teams max
        return False
    else:  #function returns true if less than 2 teams
        return True
示例#3
0
    def get_history(self):

        sql = "SELECT * FROM logs  WHERE ID = %s ORDER BY Num DESC LIMIT 5 " % self.id
        try:
            # Execute the SQL command
            cursor.execute(sql)
            # Fetch all the rows in a list of lists.
            results = cursor.fetchall()
        except:
            print "Error : Cant Fetch Data"
        # Change tuple To
        return results
示例#4
0
def usernamecheck(username):  #Function to check for an existing username
    findusername = ("SELECT * FROM users WHERE username = ?")
    cursor.execute(findusername, [(username)])
    if cursor.fetchall():
        return False  #If found, function is false and parent function stops
    elif len(username) >= 6:  #If not found, checks length of username
        if username.find(
                ' ') == -1:  #attempts to locate any spaces in username
            return True  #if checks pass the function returns true
        else:
            return False
    else:
        return False
示例#5
0
    def get_any_totaldepposite(self):

        sql = "SELECT totaldepposite FROM logs  WHERE Day1 = %s and ID = %s ORDER BY Num DESC LIMIT 1" % (
            self.day, self.id)
        try:
            # Execute the SQL command
            cursor.execute(sql)
            # Fetch all the rows in a list of lists.
            results = cursor.fetchall()
        except:
            print "Error : Cant Fetch Data"
        # Change tuple To int
        check = int(results[0][0])
        return check
示例#6
0
 def first_operation(self):
     # Count
     sql = "SELECT time1 FROM logs WHERE 1st = 1 and Day1 = %s and ID = %s" % (
         self.day, self.id)
     try:
         # Execute the SQL command
         cursor.execute(sql)
         # Fetch all the rows in a list of lists.
         results = cursor.fetchall()
     except:
         print "Error : Cant Fetch Data123"
     # Change tuple To int
     check = str(results[0][0])
     # Check = 0 if ID is not Exist // Check = 1 if ID is Exist
     return check
示例#7
0
def getbattleteams(userID):
    query = 'SELECT teamID, teamname FROM userteams WHERE userID = ?'
    cursor.execute(query, [(userID)])
    return cursor.fetchall()
示例#8
0
def getuserteams(username):
    query = 'SELECT creature1, creature2, creature3, creature4 FROM userteams WHERE userID = ?'
    cursor.execute(query, [(username)])
    teams = cursor.fetchall()
    return teams
示例#9
0
def fetchcreatures():
    query = ('SELECT creatureID, creatureName FROM creatures')
    cursor.execute(query)
    return cursor.fetchall()
    db.close()
示例#10
0
def fetchplayers():
    selectbyELO = ("SELECT username, ELO FROM users ORDER BY ELO DESC LIMIT 10")
    cursor.execute(selectbyELO)
    return cursor.fetchall()
    db.close()