<commit_before>import sqlite3
from config import DATABASE


def upsert_db(movie_list, database=DATABASE):
    try:
        db = sqlite3.connect(database)
        cur = db.cursor()

        for movie in movie_list:
            cur.execute("""
            insert or replace into Movie_List (id, Filename, Size, Path, Title,
                                                Year, tmdb_id, Overview, imdb_id,
                                                Rating, Runtime, Poster, Backdrop,
                                                Release_Date, Tagline, Date_Added)
            values ((select id from Movie_List where tmdb_id = ? and size = ?)
                    ,?,?,?,?,?,?,?,?,?,?,?,?,?,?,
                    (select Date_Added from Movie_List where tmdb_id = ? and size = ?))
            """, (movie['tmdb_id'], movie['size'], movie['filename'], movie['size'], movie['root'], movie['title'],
                  movie['year'], movie['tmdb_id'], movie['overview'], movie['imdb_id'], movie['vote_average'],
                  movie['runtime'], movie['poster_path'], movie['backdrop_path'], movie['release_date'],
                  movie['tagline'], movie['tmdb_id'], movie['size'])
            )

        db.commit()

    except Exception as e:
        db.rollback()
        raise e
    finally:
        db.close()<commit_msg>Added insert or replace command for Video table<commit_after>import sqlite3
from config import DATABASE


def upsert_db(movie_list, database=DATABASE):
    try:
        db = sqlite3.connect(database)
        cur = db.cursor()

        for movie in movie_list:
            cur.execute("""
            insert or replace into Movie_List (id, Filename, Size, Path, Title,
                                                Year, tmdb_id, Overview, imdb_id,
                                                Rating, Runtime, Poster, Backdrop,
                                                Release_Date, Tagline, Date_Added)
            values ((select id from Movie_List where tmdb_id = ? and size = ?)
                    ,?,?,?,?,?,?,?,?,?,?,?,?,?,?,
                    (select Date_Added from Movie_List where tmdb_id = ? and size = ?))
            """, (movie['tmdb_id'], movie['size'], movie['filename'], movie['size'], movie['root'], movie['title'],
                  movie['year'], movie['tmdb_id'], movie['overview'], movie['imdb_id'], movie['vote_average'],
                  movie['runtime'], movie['poster_path'], movie['backdrop_path'], movie['release_date'],
                  movie['tagline'], movie['tmdb_id'], movie['size'])
            )

        db.commit()

    except Exception as e:
        db.rollback()
        raise e
    finally:
        db.close()


def upsert_videos(video_list, database=DATABASE):
    try:
        db = sqlite3.connect(database)
        cur = db.cursor()

        for video in video_list:
            cur.execute("""
            insert or replace into Video (Video_ID, Type, Key, Name, Size, Site, Movie_id, Date_Added)

            values ((select Video_ID from Video where Movie_id = ? and Key = ?),
                    ?,?,?,?,?,?,
                    (select Date_Added from Video where Movie_id = ? and Key = ?))
            """, (video['movie_id'], video['key'], video['type'], video['key'], video['name'], video['size'],
                  video['site'], video['movie_id'], video['movie_id'], video['key'])
            )

        db.commit()

    except Exception as e:
        db.rollback()
        raise e
    finally:
        db.close()
{'fraction_non_alphanumeric': 0.14310099573257468, 'fraction_numerical': 0.001422475106685633, 'mean_word_length': 1.8585365853658538, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5343223', 'n_tokens_mistral': 973, 'n_tokens_neox': 921, 'n_words': 239}