1

I am trying to insert data into MYSQL database using a python script and when i execute my program i get an error "Not enough arguments for format string" at the following line.

_cursor.execute("INSERT INTO `md_patentinfo` (patentno, filed) 
       VALUES ('%s',STR_TO_DATE('%s','%M %d,%Y'))" %(patent_number,issue_date))

MORE INFO ON THE ABOVE LINE : in the above line i am inserting patent number and Issue date into my table and i am using the STR_TO_DATE to convert the date value in %B %d,%Y format to %M,%d,%Y.

Please help me out

0

2 Answers 2

1

You need to escape the %M, %d and %Y as in:

"INSERT INTO md_patentinfo (patentno, filed) VALUES ('%s',STR_TO_DATE('%s','%%M %%d,%%Y'))" % ('123','Apr 14,2012')
Sign up to request clarification or add additional context in comments.

1 Comment

when i use this format in .execute(query) i get: not enough arguments for format string
1

Your format string has five arguments (each '%something' is an argument). You probably want to escape the %M, %d%Y part:

"INSERT INTO md_patentinfo (patentno, filed) VALUES ('%s',STR_TO_DATE('%s','%%M %%d,%%Y'))" % (patent_number,issue_date)

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.