when i try to run this code i get error ((1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''music' ('Number', 'Song', 'Band', 'Link', 'Sad depressing', 'Dreamy', 'Anxious ' at line 1")) and i don't know why. everything seems right to me
import pymysql
def mysqladd(Number, Song, Band, Link, Sad_depressing, Dreamy, Anxious_tense, Scary_fearful, Annoying, Indignant_defiant, Energizing_pump_up, Amusing, Joyful_cheerful, Erotic_Desirous, Calm_relaxing, Beatyful):
connection = pymysql.connect(host='localhost', user='cd63913_neurohac', password='1234', database='cd63913_neurohac')
cur = connection.cursor()
#cur.execute("select @@version")
mySql_insert_query = "INSERT INTO 'music' ('Number', 'Song', 'Band', 'Link', 'Sad depressing', 'Dreamy', 'Anxious tense', 'Scary fearful', 'Annoying', 'Indignant defiant', 'Energizing pump-up', 'Amusing', 'Joyful cheerful', 'Erotic Desirous', 'Calm relaxing', 'Beatyful') VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
record = (Number, Song, Band, Link, Sad_depressing, Dreamy, Anxious_tense, Scary_fearful, Annoying, Indignant_defiant, Energizing_pump_up, Amusing, Joyful_cheerful, Erotic_Desirous, Calm_relaxing, Beatyful)
cur.execute(mySql_insert_query, record)
connection.commit()
print(cur.rowcount, "Success")
# To close the connection
connection.close()
# Driver Code
if __name__ == "__main__" :
mysqladd(8, "One Way Or Another", "Blondie", "https://youtu.be/valVixMpzQY", 10, 50, 0, 0, 0, 0, 0, 0, 100, 0, 69, 100) ```
source https://stackoverflow.com/questions/75596388/cant-insert-a-row-into-my-table-with-pymysql
Comments
Post a Comment