Fix bug in generating endpoint dumps

Only one line was dumped.
Better SQL generation routine.
Add atime and creationdate to endpoint dumps.