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.
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()
You forgot to commit the transaction .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.