2

I looked here. It fixes the error if the code is like:

"""INSERT IGNORE INTO analysing_tweet(created_at) VALUES (("%s"))""" % (tweeted_values["created_at"])

However, after talking to other people, about this error, people have said this practice is bad. So once I fixed it to like this:

query = """INSERT IGNORE INTO analysing_tweet(created_at) VALUES (("%s"))"""
values = (tweet_values["created_at"])
cursor.execute(query, values)

It executes with no problem, but in the database it adds %s, it looked like this

created_at
%s

Versions:

MySQL: 8.0.25

Python: 3.8.10

mysql-connector: 2.2.9

mysql-connector-python: 8.0.25

  • It came to the same results. When cursor.execute is doesn't seem the change the %s. Also it comes back with the old error. "mysql.connector.errors.ProgrammingError: 1064 (42000): 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 '%s)' at line 1" – Fake Disciple Jul 19 '21 at 13:48
  • Tried it both way you suggested initial way it came the same error previously and now with "('%s')" it ass "%s" to the table – Fake Disciple Jul 19 '21 at 13:57

0 Answers0