nsertMachineState :: DBInfo -> IO DBInfo
insertMachineState dbi = do
    let conn = db_connection dbi
        inlist = map (\(mid,start,duration,state) ->
            ((db_machines dbi) M.! mid, start, duration, stateToInt state))
                $ db_machinebuffer dbi
    executeMany conn insertMachineStateQuery inlist
    return dbi {db_machinebuffer = []}

insertMachineState :: DBInfo -> IO DBInfo
insertMachineState dbi = do
    let conn = db_connection dbi
        inlist = map (\(mid,start,duration,state) ->
            ((db_machines dbi) M.! mid, start, duration, stateToInt state))
                $ db_machinebuffer dbi
    executeMany conn insertMachineStateQuery inlist
    return dbi {db_machinebuffer = []}
insertMachineState dbi = do
    let conn = db_connection dbi
        inlist = map (\(mid,start,duration,state) ->
            ((db_machines dbi) M.! mid, start, duration, stateToInt state))
                $ db_machinebuffer dbi
    executeMany conn insertMachineStateQuery inlist
    return dbi {db_machinebuffer = []}