我想从主线程和后台线程访问sqlite数据库文件。问题是,无论我如何更改代码,我总是会遇到以下问题:
ProgrammingError: SQLite objects created in a thread can only be used in that same thread.The object was created in thread id -1250925472 and this is thread id -1225814016
我的代码是这样的:
engine = create_engine('sqlite:///data/storage.sqlite', poolclass=NullPool)
Footprint.Base.metadata.create_all(engine)
session_factory = sessionmaker(bind=engine)
Session = scoped_session(session_factory)
def storeData(fp):
s = Session()
s.add(fp)
s.commit()
有人知道怎么解决这个恼人的问题吗?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐