コード例 #1
0
 def insert_registration():
     sql = "insert into registration(username, password) values(%s,%s)"
     val = (
         username,
         password,
     )
     insert(sql, val)
コード例 #2
0
def new_comment(matchid):
    comment = request.form["comment"]
    matchid = matchid
    sql = "insert into msg(writer, message, matchid) VALUES (%s, %s, %s)"
    val = session["username"], comment, matchid
    insert(sql, val)
    return my_game_info(matchid)
コード例 #3
0
 def insert_person():
     sql = "insert into person(name, email, gender) values(%s,%s,%s)"
     name = fName + " " + lName
     val = (
         name,
         email,
         gender,
     )
     insert(sql, val)
コード例 #4
0
def show_past_chatt():
    messages = []
    sql = "select writer,message,date from msg WHERE writer = %s OR reciever = %s"
    val = session["username"], session["username"]
    insert(sql, val)
    messages = fetchall(sql, val)
    return render_template("messages.html",
                           user=session["username"],
                           messages=messages)
コード例 #5
0
def booking_game(matchid):
    matchid = int(matchid)
    players = request.form["players"]
    print(players)
    if players == "0":
        flash("Var vänlig och boka en plats")
        print("players = 0" + players)
        return render_template("match_profile.html",
                               match=show_match.show_Match_Profile(matchid))

    else:
        print("antal högre än 0:" + players)
        booked = fetchone("select booked from match where matchid = %s",
                          [matchid])

        def new_booked():
            print(players)
            if (int(players) + booked[0]) > 4:
                return "4"
            else:
                return int(players) + booked[0]

            print(matchid, session["username"])

        creatorName = fetchone("select creator from match where matchid = %s",
                               [matchid])
        sql = "insert into booking values(%s,%s,%s,%s)"
        val = matchid, session["username"], creatorName, players
        insert(sql, val)

        sql = "UPDATE match SET booked = %s WHERE matchid = %s;"
        val = new_booked(), matchid
        update(sql, val)

        sql = "UPDATE match SET players = %s WHERE matchid = %s;"
        searching = fetchone("select players from match where matchid = %s",
                             [matchid])
        print(searching[0])
        searching = searching[0] - int(players)
        val = searching, matchid
        update(sql, val)

        return start_page()

    sql = "UPDATE match SET players = %s WHERE matchid = %s;"
    searching = fetchone("select players from match where matchid = %s",
                         [matchid])
    print(searching[0])
    searching = searching[0] - int(players)
    val = searching, matchid
    update(sql, val)

    return start_page()
コード例 #6
0
def insert_match():

    players = request.form["players"]

    show_match.create_Game(session["username"])
    matchid = fetchone("select max(matchid) from match where matchid > %s",
                       "0")
    if matchid[0] == None:
        matchid = 1
    sql = "insert into booking (matchid,username,creatorname,booked) values (%s,%s,%s,%s)"
    val = matchid, session["username"], session["username"], players
    insert(sql, val)

    return start_page()
コード例 #7
0
def upload(file):
    uploaded_file = file.filename
    now = date.today()
    filename = uploaded_file
    extension = uploaded_file.split(".")[-1]
    checkName = db_operations.checkIfFileNameExists(filename)
    if checkName:
        db_operations.insert(filename, now, extension, size=0)
    else:
        newFileName = db_operations.extendFileName(filename)
        filename = newFileName
        db_operations.insert(filename, now, extension, size=0)
    load_File(file, filename)
    path = "/app/saved_files/" + filename
    file_size = os.stat(path).st_size
    print(file_size, flush=True)
    db_operations.update_size(filename, file_size)
    current_row = db_operations.get_row_by_filename(filename)
    return current_row.id
コード例 #8
0
def insert_match():

    ort = request.form["ort"]
    klass = request.form["klass"]
    antal = request.form["antal"]

    show_match.create_Game(session["username"])
    matchid = fetchone("select max(matchid) from match where matchid > %s",
                       "0")
    print(matchid)
    if matchid[0] == None:
        matchid = 1
        print(matchid)
    sql = "insert into booking (matchid,username,creatorname) values (%s,%s,%s)"
    val = matchid, session["username"], session["username"]
    insert(sql, val)
    print(matchid, session["username"])

    return render_template("find_match.html",
                           games=show_match.show_Game(ort, klass, antal))
コード例 #9
0
def show_chatt(matchid):
    matchid = int(matchid)
    print(matchid)
    antal = request.form["antal"]
    booked = fetchone("select booked from match where matchid = %s", [matchid])
    print(booked[0])
    new_booked = int(antal) + booked[0]
    print(matchid, session["username"])

    creatorName = fetchone("select skapare from match where matchid = %s",
                           [matchid])
    sql = "insert into booking values(%s,%s,%s)"
    val = matchid, session["username"], creatorName
    insert(sql, val)

    sql = "UPDATE match SET booked = %s WHERE matchid = %s;"
    val = new_booked, matchid
    print(matchid, session["username"])
    update(sql, val)

    sql = "UPDATE match SET antal = %s WHERE matchid = %s;"
    sökes = fetchone("select antal from match where matchid = %s", [matchid])
    print(sökes[0])
    sökes = sökes[0] - int(antal)
    val = sökes, matchid
    update(sql, val)

    # Future chatt fnction
    # def sessions():
    #     return render_template('session.html')

    # def messageReceived(methods=['GET', 'POST']):
    #     print('message was received!!!')

    # @socketio.on('my event')
    # def handle_my_custom_event(json, methods=['GET', 'POST']):
    #     print('received my event: ' + str(json))
    #     socketio.emit('my response', json, callback=messageReceived)
    # return render_template('session.html')

    return start_page()
コード例 #10
0
def get_comments() -> bytes:
    """
    :return: comments for the received status_id
    """
    # Extract the received status_id

    status_id: str = request.args.get('status_id')

    # Fetch rows from DB using the status_id

    comments = select(status_id, table='status_text', column='comments')

    # if comments diff from "" there are comments

    if comments:
        return jsonify({"comments": literal_eval(comments)})

    # If the we didn't returned yet, we need get the comments from the web and store it in the DB

    status_text, comments = get_data_from_web(status_id)

    insert(status_id, status_text, comments)

    return jsonify({"comments": literal_eval(comments)})
コード例 #11
0
ファイル: main.py プロジェクト: py-Tom/NCtoAS
 def operation(self, table):
     operation_chosen = self.operation_chosen.get()
     if operation_chosen == "New":
         self.forget_all()
         self.label_name.pack()
         self.new_name.pack()
         self.label_coord.pack()
         self.new_coord.pack()
         self.accept_button.pack()
         self.accept_button.configure(command=lambda: [
             insert(table, self.new_name_value.get(),
                    self.new_coord_value.get()),
             self.update_values(table),
             self.window.destroy(),
         ])
     elif operation_chosen == "Update":
         self.forget_all()
         self.label_name.pack()
         self.old_values.pack()
         self.label_coord.pack()
         self.new_coord.pack()
         self.accept_button.pack()
         self.accept_button.configure(command=lambda: [
             update(table, self.old_chosen.get(), self.new_coord_value.get(
             )),
             self.update_values(table),
             self.window.destroy(),
         ])
     elif operation_chosen == "Delete":
         self.forget_all()
         self.label_name.pack()
         self.old_values.pack()
         self.accept_button.pack()
         self.accept_button.configure(command=lambda: [
             remove(table, self.old_chosen.get()),
             self.update_values(table),
             self.window.destroy(),
         ])
     else:
         raise ValueError
     return None
コード例 #12
0
ファイル: app.py プロジェクト: sambapython/batch49
import db_operations
while True:
    print """
	1. insert
	2. update
	3. delete
	4. show
	q. quit
	"""
    opt = raw_input("Enter an option:")
    if opt.lower() == "q" or opt.lower() == "quit":
        print "thank you!!"
        break
    if opt == "1":
        db_operations.insert()
    elif opt == "2":
        db_operations.update()
    elif opt == "3":
        db_operations.delete()
    elif opt == "4":
        print db_operations.browse()
    else:
        print "wrong option"
コード例 #13
0
 def insert_profile():
     sql = "insert into profile(img, level, location) values(%s, %s, %s)"
     image = 'static/img/uploads/blank_profile.png'
     val = (image, level, location)
     insert(sql, val)