Writes each session to SQL table