The reason the 1 query is working fine is due to the reason that the whole query is written within the inverted comma which is the correct format to execute Mysql query in python .