Sanitize rows before inserting into sqlite

Change-Id: Id729fa77581fa71e056aec2cc2a3769a4acef4e5