Exemplo n.º 1
0
def storeteam(ID, creature1, creature2, creature3, creature4):

    storequery = (
        '''INSERT INTO userteams(userID, creature1, creature2, creature3, creature4)
    VALUES(?, ?, ?, ?, ?)''')  #creates the INSERT INTO query
    cursor.execute(storequery, [(ID), (creature1[1]), (creature2[1]),
                                (creature3[1]), (creature4[1])])
    db.commit()  #commits the query to the database
Exemplo n.º 2
0
 def insert_operation(self, totalwithdraw, totaldepposite):
     sql = "INSERT INTO logs (ID, Date1 ,Day1, time1, operation, 1st, totalwithdraw, totaldepposite) VALUES ('%s','%s" \
           "','%s','%s','%s', '%s', '%s', '%s')" % (self.id, self.date, self.day, self.time, self.operation, self.st1, totalwithdraw, totaldepposite)
     try:
         # Execute the SQL command
         cursor.execute(sql)
         # Commit your changes in the database
         db.commit()
         print " succ"
     except:
         # Rollback in case there is any error
         print "error"
         db.rollback()
Exemplo n.º 3
0
def updateelo(userID, battlestate):
    fetchELO = '''SELECT ELO FROM users WHERE userID=?'''  #query to get ELO
    setELO = '''UPDATE users SET ELO = ? WHERE userID = ? '''  #Query to update ELO
    cursor.execute(fetchELO, [(userID)])  #executes get query
    currentELO = cursor.fetchone()[0]  #places result in variable
    print(f"Current ELO is {currentELO}")
    if battlestate == True:  #if battle is a win the ELO increases by 5%
        newELO = currentELO + (currentELO * 0.05)
    elif battlestate == False:  #if battle is a loss ELO decreases by 10%
        newELO = currentELO - (currentELO * 0.1)
    print(f"New ELO is {newELO}")
    cursor.execute(setELO, [(newELO), (userID)])  #sets the new ELO
    db.commit()
    db.close()
Exemplo n.º 4
0
def registeringprocess(username, email, password, confirmpassword):
    if usernamecheck(username):  #Runs the data through each function
        if emailcheck(email):
            if passwordcheck(password, confirmpassword):
                print(username, email, password)  #test data
                insertData = '''INSERT INTO users(username, emailaddress, password, ELO)
                VALUES(?, ?, ?, 100)'''
                cursor.execute(insertData, [(username), (email), (password)])
                db.commit(
                )  #The data is only written to the database if all checks pass.
                db.close()
                print("Successful Register")
                return True
            else:

                return "Password Check Issue"
        else:
            return "Email Check Issue"
    else:
        return "Username Already Exists!"