0

using python adbapi the insert a row in a table in mysql

like insert ,id is a int, value is a blob

db.runQuery("INSERT INTO t (id, blob_value) VALUES (%(id)s, %(blob_value)s)", \
{
    "id" : id,
    "blob_value" : blob_value
}

Traceback: <class '_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 INSERT INTO t (id, blob_value) VALUES (%(id)s, %(blob_value)s)",

and I think it could be a quote character - ' in the blob_value, is these the matter why it failed?

OK, the reason is the table name - "unlock" which is a key word of mysql.

Would any one help how to do delete a table named "unlock"?

4
  • What happens when you run the same code with a blob_value not containing any quotes? Commented May 7, 2012 at 10:14
  • thanks, i test it with an string without quote, the error still exists. Commented May 7, 2012 at 10:32
  • Do you have the necessary quotation marks around the blob? Is the blob really text only? Otherwise you will have to deal with it in a different kind i think Commented May 7, 2012 at 12:15
  • I know the problem, i named the table "unlock" which is a key word of mysql. so a create a table named "unlock" i can't use it anymore. the question is how to delete the table "unlock" after all. Commented May 7, 2012 at 12:22

2 Answers 2

1

Short answers:

DROP TABLE `UNLOCK`
SELECT * FROM `UNLOCK`

Use the mighty `

Sign up to request clarification or add additional context in comments.

Comments

1

Just put backticks around the table name:

drop table `unlock`;

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.