Forums

Why my pythonanywhere db (mysql) does not insert all data?

Hi, I have a problem with PA db. I'm inserting records which consist of strings, like id, title, link etc. When the particular record has youtube link in it - it is not inserted into db. I do not have any error or anything, it just doesn't show up in my db. I've tested my insert statement with my localdb - all data is correctly inserted and I can SELECT them. My PA account is "dev plan". This is my code:

mydb = mysql.connector.connect(
  host='me.mysql.pythonanywhere-services.com',
  user='me',
  password='pass',
  database='my$db',
  port='3306',

)

sql = "INSERT IGNORE INTO mydb(id, link, title, date, image, description, tag) VALUES(%s, %s, %s, %s, %s, %s, %s)"
mycursor.executemany(sql, mydata)
mydb.commit()
mycursor.close()
mydb.close()

SOLVED - for anyone with similar problem - check your "Unique Index" field on db, if you have "IGNORE" within your statement - you will face the same situation as me :)