1

I am attempting to write a SQL in python using PYMYSQL, which searches a table for a certain record with a set value, however while this sounds simple I cannot seem to do it below is my query:

SELECT Series_ID FROM series_information WHERE Series_Name "'+data +'"'

where the data is the value that I am searching for however the following error occurs:

pymysql.err.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 \'"Spice And Wolf"\' at line 1')

The problem I believe is that I am not sure how to properly escape the data value if it has spaces in it and therefore would require quotation marks in the SQL query.

0

2 Answers 2

1

You're missing a comparison (like, =, etc) between Series_Name and data, as well as a ';' on the end of the query.

`'SELECT Series_ID FROM series_information WHERE Series_Name = "'+data +'";'

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

1 Comment

Many thanks i guess the documentaiton i look at was wrong ;/ but thanks !
0
`SELECT Series_ID FROM series_information WHERE Series_Name "'+data +'"'`

Is not a valid SQL query did you mean:

`'SELECT Series_ID FROM series_information WHERE Series_Name like "'+data +'"'`

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.