#1
  1. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,465
    Rep Power
    653

    MySQL INSERT Problem


    I am trying to insert a row into a table with this code:
    Code:
     query="INSERT INTO Members VALUE ('"+args["first"].value+"','"+args["last"].value+"','"+mac+\
                                    "','"+args["email"].value+"',false,'','');"
                            try:
                                    rows=cur.execute(query)
                                    print("Success - ",rows)
                            except (MySQLdb.Error,MySQLdb.Warning) as e:
                                    print("Error:  [%d] - %s" % (e.args[0], e.args[1]))
    I am getting the "Success" output with 1 row. However, when I manually do a "select * from Members" the empty set is returned. Obviously in spite of the row count being 1, nothing was added to the table. I have no clue how to debug this since it looks like a success from Python. Can someone explain how this is possible or how to debug it? TIA.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,465
    Rep Power
    653
    Never mind. I found the problem. I forgot db.commit().
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,465
    Rep Power
    653
    Closing thread.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.

IMN logo majestic logo threadwatch logo seochat tools logo