2

I keep running into an error from the following statement:

cursor.execute("""INSERT into financial_statements (url) 
                  VALUES (%s) WHERE provider=%s AND date=%s""", (url, provider, date))

The error I get is:

_mysql_exceptions.ProgrammingError: (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 
'WHERE provider='ANGEL' AND date='2012-03-01'' at line 2")

2 Answers 2

5

You can't have a WHERE clause for an INSERT statement.

Maybe you meant to perform an UPDATE?

UPDATE financial_statements
SET url = %s
WHERE provider=%s AND date=%s
Sign up to request clarification or add additional context in comments.

1 Comment

Ahh, forgot about that. Thanks
4

It makes no sense to use WHERE in an INSERT statement - there is nothing to restrict.

If you want to modify an existing row, use UPDATE:

UPDATE financial_statements SET url=%s WHERE provider=%s and DATE=%s

Comments

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.