Added some extra assertions and logging around database methods.
Added some extra assertions and logging around database methods.

Acidburn0zzz/sdk,meganz/sdk,Acidburn0zzz/sdk,Acidburn0zzz/sdk,Acidburn0zzz/sdk,meganz/sdk,meganz/sdk,Acidburn0zzz/sdk,meganz/sdk,Acidburn0zzz/sdk,meganz/sdk,Acidburn0zzz/sdk,meganz/sdk,Acidburn0zzz/sdk,meganz/sdk