add get_database_connection and teardown_request to handle db on flask.g
add local journal entry capability and tests