Forum Discussion
Write Back to MongoDB from Power BI
- Anonymous3 years ago
Hoping to be able to help someone, I leave the solution found.
Code for the MongoDB Insert function:= Table.AddColumn(#"Changed Type", "MongoDB Insert", each "{
'id':" & Text.From([ID]) & ",
'start_time': '" & Text.From([start_time]) & "',
'feedback': '" & Text.From([feedback]) & "'}")Code for the invoked function:
(insert_statement as text)=>
letInsert = Python.Execute("import pymongo; client = pymongo.MongoClient('mongodb://localhost:27017/'); db = client['database-name']; collection = db['collection-name']; data = " & insert_statement & "; result = collection.insert_one(data);")
in
InsertThanks!!
Hoping to be able to help someone, I leave the solution found.
Code for the MongoDB Insert function:
= Table.AddColumn(#"Changed Type", "MongoDB Insert", each "{
'id':" & Text.From([ID]) & ",
'start_time': '" & Text.From([start_time]) & "',
'feedback': '" & Text.From([feedback]) & "'}")
Code for the invoked function:
(insert_statement as text)=>
let
Insert = Python.Execute("import pymongo; client = pymongo.MongoClient('mongodb://localhost:27017/'); db = client['database-name']; collection = db['collection-name']; data = " & insert_statement & "; result = collection.insert_one(data);")
in
Insert
Thanks!!