1

I use the following query:

cur.executemany(sql, data)
conn.commit()

Where data is:

[('ON-LOOK', 'ONLOOK KOREA', '[email protected]', 'Entertainment', '1.287', 'USK: All ages', 'https://www.google.com/url', 'https://ama.com', 'December 13, 2016', '//lh3.googleusercontent.com/bZrL9zRTXujVSFsNS_vD8AomApZeP2xgI1vGTsOz_zvoVKOz5T9pk7nFB3ONXXf04rqj=w300', '100 - 500', '4.7', '6', '4.3 and up')]

And sql is:

sql = """insert into apps_global (app_name, app_developer, app_email, app_category, app_version, app_age, app_website, app_url, app_developer_url, app_updated, app_image, app_installations, app_score, app_score_count, app_android \
      ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')"""

When I try to execute query I get error:

ProgrammingError(1064, "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 'ON-LOOK'', ''ONLOOK KOREA'', ''[email protected]'', ''Entertainment'', ''1.28' at line 1", u'42000'))

How to fix it?

4
  • 3
    In your sql, replace %s with placeholder ? Commented Dec 21, 2016 at 18:50
  • 1
    replace all %s to ? ? or on %? Commented Dec 21, 2016 at 18:51
  • it works, but sometimes I get another error: InterfaceError(-1, 'Use cmd_query_iter for statements with multiple queries.', None)) Commented Dec 21, 2016 at 19:10
  • try this for InterfaceError above Commented Dec 21, 2016 at 22:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.