def writeToMongo():
 sys.stderr.write('Saving to db.messages.errors, will not check for duplicates!')
 from pymongo import Connection
 connection = Connection()
 db = connection['messages']
 errorcodes = db['errors']
 for errCode in messages.keys():
  sys.stderr.write('Inserting code: {}\n'.format(errCode))
  result = errorcodes.insert(messages[errCode])
  sys.stderr.write('Result: {}\n'.format(result))

def writeToMongo ( ) : sys . stderr . write ( 'Saving to db.messages.errors, will not check for duplicates!' ) from pymongo import Connection connection = Connection ( ) db = connection [ 'messages' ] errorcodes = db [ 'errors' ] for errCode in messages . keys ( ) : sys . stderr . write ( 'Inserting code: {}\n' . format ( errCode ) ) result = errorcodes . insert ( messages [ errCode ] ) sys . stderr . write ( 'Result: {}\n' . format ( result ) )
pipe the messages array into mongodb .