是否可以在打开 SQLObject 连接后手动关闭它?我试图在使用数据库文件后删除它,但似乎与数据库文件的打开连接阻止了我这样做。
例如:
from sqlobject import *
import os
# Create and open connection to a database file.
sqlhub.processConnection = connectionForURI('sqlite:path_to_db')
SomeObject.createTable()
# ...
# Delete database when finished.
os.remove('path_to_db')
给出以下错误:
WindowsError: [Error 32] The process cannot access the file because
it is being used by another process: 'path_to_db'