Reputation: 892
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.
Upvotes: 3
Views: 832
Reputation: 61
add "COMMIT" at the end of command
for example:
cursor.execute("INSERT INTO games (userid) VALUES(%s);COMMIT;" % id)
set autocommit by add the second line
db = MySQLdb.connect(user='username', db=dbName,) # exmaple
db.autocommit(1) # enable auto commit
add commit() after transaction
db.commit()
Upvotes: 6