0

I'm using oracle 11g as a DB and idk why my code is not working

@app.route('/add-game', methods=['POST', 'GET'])
def addGame():
    if request.method == 'GET':
        return render_template('add_game.html')
    elif request.method == 'POST':
        game_name= request.form['game_name']
        print(game_name)
        qry = "INSERT INTO GLP.game (game_title) VALUES (:1)"
        cur.execute(qry, (game_name))
        conn.commit()
        return render_template("index.html", context=None)
      

HERE IS THE ERROR THAT I'M GETTING

 line 38, in addGame
    cur.execute(qry, ('game_name'))
cx_Oracle.DatabaseError: ORA-01036: illegal variable name/number
127.0.0.1 - - [27/Nov/2022 16:47:58] "POST /add-game HTTP/1.1" 500 -

I need help to solve this issue, Thanks in advance

Nabeel Ahmed
  • 130
  • 7
  • 1
    `(game_name)` is **not a tuple**. Use `[game_name]` or `(game_name,)` to make it an actual sequence (a list or a tuple with a single element). Right now, `(game_name)` is just the same thing as `game_name`, and a string is a sequence too, which in your case probably has more than 1 character in it. – Martijn Pieters Nov 27 '22 at 11:56

0 Answers0