1

Trying to query AWS database (newbie to this). Query is as below:

dfHealthData = pd.read_sql("SELECT YearStart, LocationDesc, Topic, Question, DataValue "
                               "FROM HealthData WHERE YearStart = '2018' AND DataValueType = 'Crude Prevalence' AND Question LIKE '%18 years'" , connection_string)   

Want to get string which ends in ' 18 years' (or ideally '>=18 years', but the former will do).

Error is as below. Error retrieving from AWS: unsupported format character ' ' (0x20) at index 161

2
  • Looking at the character count it appears it does not like the space within '%18 years', unfortunately I am not too sure why, try '%18%years'?
    – User1010
    Apr 19, 2020 at 10:53
  • Yes I thought that myself but I am absolutely sure it is. I think it must count the whitespace between the 2 lines or something.
    – user3600952
    Apr 19, 2020 at 10:55

1 Answer 1

2

% has a special meaning in python. Try to escape it:

dfHealthData = pd.read_sql("SELECT YearStart, LocationDesc, Topic, Question, DataValue FROM HealthData WHERE YearStart = '2018' AND DataValueType = 'Crude Prevalence' AND Question LIKE '%%18 years'" , connection_string)
1
  • Thanks! That is the answer.
    – user3600952
    Apr 19, 2020 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.