import re


def quote_apostrophes(value):
    """Format single quotes for SQLite.
    See:
        * http://www.sqlite.org/lang_expr.html
        * http://stackoverflow.com/questions/603572/
            how-to-properly-escape-a-single-quote-for-a-sqlite-database
    """
    return re.sub("'", "''", value)