add pymongo exception and two connection ways(safe mode for old connection)