You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2021/10/08 18:25:30 UTC
[GitHub] [openwhisk] jovans2 opened a new issue #5166: Python + MongoDB + OpenWhisk
jovans2 opened a new issue #5166:
URL: https://github.com/apache/openwhisk/issues/5166
Hello,
I have the following setup: the "Standalone" OpenWhisk stack and locally deployed MongoDB. I want to create actions that can read from database. Such as this example:
`
import pymongo
def main(params):
myclient = pymongo.MongoClient("mongodb://localhost:27017/")
mydb = myclient["mydatabase"]
mycol = mydb["users"]
username = params["username"]
password = params["password"]
myquery = {"username":username}
mydoc = mycol.find(myquery)
if(mydoc.count() == 0):
#username not found
return {"Fail":"Username not found"}
for x in mydoc:
if(x["password"] != password):
#password incorrect
return {"Fail":"Password is incorrect"}
#username and password match
return {"Success":username}
`
However, I tried with two approaches: Docker and zip.
wsk action create login-pymongo --docker jovanvr97/python3action:pymongo-libs login.py
wsk action invoke login-pymongo --param username jovan --param password 123 --result
The output is:
{
"error": "The action did not return a dictionary."
}
Could you please tell me how should I proceed?
Thank you!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@openwhisk.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [openwhisk] rabbah closed issue #5166: Python + MongoDB + OpenWhisk // SOLVED
Posted by GitBox <gi...@apache.org>.
rabbah closed issue #5166:
URL: https://github.com/apache/openwhisk/issues/5166
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@openwhisk.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [openwhisk] rabbah commented on issue #5166: Python + MongoDB + OpenWhisk // SOLVED
Posted by GitBox <gi...@apache.org>.
rabbah commented on issue #5166:
URL: https://github.com/apache/openwhisk/issues/5166#issuecomment-943338696
Are there any logs from the activation?
I suspect the issue is this `mongodb://localhost:27017` the `localhost` here being local to the container where your function runs and not actually on your host machine.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@openwhisk.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org