sql to main thread