def to_sql_format(title):
    """Convert a page title or username to 'canonical' SQL format.

    SQL format uses underscores instead of spaces, and capitalizes the first
    letter.
    """
    title = title.replace(" ", "_")
    if not title:
        return ""
    return title[0].upper() + title[1:]