Added ability to write to SQL database