If your database isn’t massive and you are carrying out lots of operations on it, it can be much faster to load it into memory instead of working with disk access

Opening an existing SQLite database into memory
    #Open the database to work on from files
    #db1 = sqlite3.connect('my_database_file.db3')
    #db1cursor = db1.cursor()

    #Open the database into memory
    db1_source = sqlite3.connect('my_database_file.db3')
    db1 = sqlite3.connect(':memory:')
    db1_source.backup(db1)
    db1cursor = db1.cursor()
    db1_source.close()
Saving an in memory SQLite database to file
    #Close the database if opened from file
    #db1.close()
    
    #Close the database out of memory to file
    db1_output = sqlite3.connect('my_database_file.db3')
    db1.backup(db1_output)
    db1.close()
    db1_output.close()