Here's a simplified example of my problem:
import os
import sqlite3
with sqlite3.connect('test.db.temp') as db:
db.executescript('CREATE TABLE foo (bar);')
os.rename('test.db.temp', 'test.db')
Output:
> python test.py
Traceback (most recent call last):
File "test.py", line 7, in <module>
os.rename('test.db.temp', 'test.db')
WindowsError: [Error 32] The process cannot access the file because it is being used by another process
Background: I'm attempting to create a database in an "atomic" way, the simplest way to do that is create the database at a temporary location and then move it.