错误:

ProgrammingError: SQLite objects created in a thread can only be used in that same thread.The object was created in thread id and this is thread

解决方式:

sqlite3.connect(fp, check_same_thread = False)

如果用了sqlalchemy,则使用connect_args

engine = create_engine('sqlite:///{url}'.format(url=url), echo=True, connect_args={"check_same_thread": False})