pymongo


Spark Streaming: foreachRDD insert into mongoDB using python?


please help me in writing the insertmongo function for a spark streaming job.
it is a word count program
import pymongo_spark
........
counts = lines.flatMap(lambda line: line.split(" ")).map(lambda word: (word,1)).reduceByKey(lambda a, b: a+b)
counts = counts.map(lambda x:"word":x[0],"count":int(x[1]),"ts":str(uuid1())})
def insertMongo(time,rdd):
rdd.saveToMongoDB('mongodb://localhost:27017/telematics.test')
counts.foreachRDD(insertMongo)

Related Links

pymongo upgrade to 3.0.3 causes this statement to fail
UUID to NUUID in Python
how to test for empty mongodb query in pymong
read video file from mongodb with pymongo
Get OperationFailure error with PyMongo 2.7.1
Inserting string as regular string in mongodb
Mongos + Pymongo 2.5 ==>No suitable hosts found
pymongo collection add item using update
How to convert objectid to string
Conditional atomic mongo remove with different results
python script to connect to mongodb master
flask-admin and pymongo search
Running code when mongoengine loads a document
Can't replace mongo document
How do I call a function with pymongo using webpy?
python motor offers fetch_next exception on aggregation

Categories

HOME
office365
knockout.js
embedded-resource
slider
mongoid
supercollider
angular2-template
timber
lda
fasm
documentum
mpu6050
dma
tomcat8
mixpanel
varnish-vcl
scheduled-tasks
infrared
pfobject
fido-u2f
mime-types
candlestick-chart
function-points
msdeploy
openbravo
microsoft-certifications
shapeless
cloveretl
markov-chains
testlink
iscroll
best-buy-api
optionaldataexception
jqgrid-asp.net
cordova-ios
sonatype
spring.net
punctuation
bpms
yui3
nclam
spring-mongo
node.js-connect
odp.net-managed
adjacency-list
currency-exchange-rates
onepage-checkout
servicestack-bsd
linuxbrew
srv-record
espresso
unhandled
360-degrees
abstract-factory
mxe
baseadapter
fat32
object-code
xcode6.3.1
treeline
network-printers
forceclose
redpitaya
air-native-extension
roxy-fileman
proxy-server
progress-db
ember-table
notin
cmath
xcode4.5
audiotoolbox
popup-blocker
algol68
kolite
simile
asp.net-mvc-views
mongrel2
ccnet-config
mysqli-multi-query
source-code-protection
downcasting
ntruencrypt
stretchblt
objectinstantiation
activex-exe

Resources

Encrypt Message