Skip to content

How to initialize a new cache instance after one was already initialized during run time? #587

Discussion options

You must be logged in to vote

In the end I manually manipulated the sqlite database using this function:

def reset_cache():
    sqlite_file = f"sqlite.db"

    if Path(sqlite_file).exists():

        conn = sqlite3.connect(sqlite_file)
        c = conn.cursor()

        get_table_query = """SELECT name FROM sqlite_master WHERE type='table';"""
        c.execute(get_table_query)
        table_names = [t[0] for t in c.fetchall()]
        for table in table_names:
            c.execute(f'DELETE FROM {table};')

        conn.commit()
        conn.close()

    faiss_file = f"faiss.index"
    if Path(faiss_file).exists():
        os.remove(faiss_file)

The question is - does this truly behave as though the cache was recreat…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@mayalinetsky-kryon
Comment options

@mayalinetsky-kryon
Comment options

Answer selected by mayalinetsky-kryon
@SimFG
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants