2

have a collection in mongodb called 'collection' and I need to do and upsert using pymongo.

collection.update_one({'_id': workflowID}, {
   '$set': {'repop': repop}, {'data': workflow__list()__}
}, upsert = True, multi = False)

but I get 'SyntaxError: invalid syntax' with the little up arrow pointing under the 'o' in the repop object being stored as "repop".

I've looked at all the syntax in the world on this and this appears correct to me. Any tips?

Salvador Dali
  • 214,103
  • 147
  • 703
  • 753
Connor G.
  • 23
  • 1
  • 4

1 Answers1

3

There are a lot of things wrong with your query.

  • The update_one method doesn't have the multi option
  • The update argument in your query should be:

    {'$set': {'repop': repop, 'data': workflow__list()__}}
    

Not

{'$set': {'repop': repop}, {'data': workflow__list()__}}
                       ^^^^^ 
styvane
  • 59,869
  • 19
  • 150
  • 156