I am trying to populate my database with the follow script which does not run the query at all, instead it goes straight to the except and print the error message. Can anyone identify the problem with the function called insertGuest():
for i in range (100):
addGuest = "INSERT INTO hotel_guests VALUES (\"%d\", \"%s\"%s \"%s\")", (int(i), "Name"+str(i),"gender"+str(i))
try:
mycursor.execute(addGuest)
conn.commit()
print ("10000 Guests Successfully Inserted")
except:
conn.rollback()
print ("An error occurred")
I would also like the data, especially the name to be meaningful, but if i can on get random strings then that will just have to do.
Thanks Summer
tracebackto yourexceptso you know why it's giving you the error. Other than that this is a "Why isn't my code working" question which is off-topic to SO.