3

This is my first question on stackoverflow! I'm currently programming a steamcommunity crawler, which crawls through the steam profiles and saves things like owned games, steamname, friends, ... But when I try to run the insert command it just does NOTHING.

 if not self.check_user('games', id):
  print "insert"
  self.cursor.execute("INSERT INTO games (userid) VALUES(%s);" % id)

The program displays "insert" but the execute command does neither throw an exception, nor inserts something to the database. In addition, an eventualy happening exception is not caught. When I forexample change the query towards "INSERT INTO games (useridd)", the program quits and I see the exception.

The application is multithreaded but acquired before executing, so I can't see any issue in that.

2 Answers 2

6
  1. add "COMMIT" at the end of command

    for example:

    cursor.execute("INSERT INTO games (userid) VALUES(%s);COMMIT;" % id)
    
  2. set autocommit by add the second line

    db = MySQLdb.connect(user='username', db=dbName,) # exmaple
    db.autocommit(1) # enable auto commit
    
  3. add commit() after transaction

    db.commit()
    
Sign up to request clarification or add additional context in comments.

Comments

5

You forgot to commit the transaction.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.