withState package:sqlite-simple

Opens a prepared statement, executes an action using this statement, and closes the statement, even in the presence of exceptions.