def encode_string(s):
    """
    Simple utility function to make sure a string is proper
    to be used in a SQL query
    EXAMPLE:
      That's my boy! -> N'That''s my boy!'
    """
    res = "N'"+s.replace("'","''")+"'"
    res = res.replace("\\''","''")
    res = res.replace("\''","''")
    return res