[fix] Escape special characters as per MySQLdb

Instead of individually escaping special characters as and when issues arise, let's use MySQLdb's escape_string method