def METHOD_NAME(cursor):
    """This function create albums from all detected thing on photos"""
    SQL = """
        with {}
        insert into api_albumthing (title, thing_type,favorited, owner_id)
        select api_albumthing_sql.*
        from api_albumthing_sql
        left join api_albumthing using (title, thing_type, owner_id)
        where  api_albumthing is null;
    """.replace(
        "{}", view_api_album_thing_sql
    )
    cursor.execute(SQL)