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.

vaultah
46.9k13 gold badges120 silver badges145 bronze badges
asked Jul 15, 2015 at 20:30
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 +'";'

answered Jul 15, 2015 at 20:35
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 +'"'`
answered Jul 15, 2015 at 20:36

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.