I have below query to select rows as per the where
condition;
top4_hr_visits = pysqldf("SELECT room_name, hour, COUNT(DISTINCT user) AS user_cnt FROM user_data
WHERE room_name ='Emilio's Room' OR room_name= 'Azalea's Room'
GROUP BY room_name, hour;")
But I am getting following error;
OperationalError: near "s": syntax error
Is there a way to properly escape it? Help is appreciated.
Single quotes are escaped by doubling them up, just as you've shown us in your example replace single quote by adding another one
"SELECT room_name, hour, COUNT(DISTINCT user) AS user_cnt FROM user_data
WHERE room_name ='Emilio''s Room' OR room_name= 'Azalea''s Room'
GROUP BY room_name, hour;"