refactor code for turning stats to blob

This function is needed for the export/import commands, so move it
somewhere reusable.

Change-Id: I4d308e622925cec30cd9462d74ec2bae511e5902
Add missing argument to end_run in replay

Change-Id: I12f4accf06661b2d7e9df7efcb834c696d0f10eb
Add traceback to Run objects

Change-Id: Ia68abaaea4879148b083ae3080161341773b0c0f
refactor database initialization code

Change-Id: Iaf9a51f1220bad943163216c1d538dd89eb3bb08
add export command

Change-Id: I500b7a6d995f6cead231e256fae7c1995e374f8a
add import command

Change-Id: I1bcdd2ce8f66477ba095dec89623da25bf93d7ac