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

hjpotter92
81.1k36 gold badges148 silver badges188 bronze badges
asked Apr 19, 2012 at 22:01
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')
answered Apr 19, 2012 at 22:07
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)
answered Apr 19, 2012 at 22:12

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.