'Returns the quoted, escaped string (e.g., "\'a bird\'s feathers\'") for database entry.
Anything that is not a string (e.g., an integer) is converted to string.
Booleans are converted to "0" and "1", None is converted to "null".'

def escape(self, value):

    def quote(string):
        if (self.type == MYSQL):
            return ("'%s'" % string.replace("'", "\\'"))
        if (self.type == SQLITE):
            return ("'%s'" % string.replace("'", "''"))
    return _escape(value, quote)
