nsertThreadState :: DBInfo -> IO DBInfo
insertThreadState dbi = do
    let conn = db_connection dbi
        inlist = map (\(mid,tid,start,duration,state) ->
            ((db_threads dbi) M.! (mid,tid), start, duration, stateToInt state))
                $ db_threadbuffer dbi
    executeMany conn insertThreadStateQuery inlist
    return dbi {db_threadbuffer = []}

insertThreadState :: DBInfo -> IO DBInfo
insertThreadState dbi = do
    let conn = db_connection dbi
        inlist = map (\(mid,tid,start,duration,state) ->
            ((db_threads dbi) M.! (mid,tid), start, duration, stateToInt state))
                $ db_threadbuffer dbi
    executeMany conn insertThreadStateQuery inlist
    return dbi {db_threadbuffer = []}
insertThreadState dbi = do
    let conn = db_connection dbi
        inlist = map (\(mid,tid,start,duration,state) ->
            ((db_threads dbi) M.! (mid,tid), start, duration, stateToInt state))
                $ db_threadbuffer dbi
    executeMany conn insertThreadStateQuery inlist
    return dbi {db_threadbuffer = []}