Using mongodb+srv:// URIs with eve

1,177 views
Skip to first unread message

joan...@gmail.com

unread,
Jul 23, 2018, 12:39:38 PM7/23/18
to Eve REST Framework
Hi,
I am trying to use mongodb+srv:// URIs with eve. The project uses the latest version eve

I get this error when trying to the hit an endpoint :

The "dnspython" module must be installed to use mongodb+srv:// URIs

What is the config needed to tell pymongo parser to parse a mongo+srv URI.

I know the code is looking for _HAVE_DNSPYTHON flag but not sure how I configure that.
I know this flag is imported like this: from pymongo.uri_parser import parse_uri, split_hosts, _HAVE_DNSPYTHON

Do I need to pass a flag in MONGO_OPTIONS?

Any help will be greatly appreciated!


Gabriel Wainer

unread,
Jul 23, 2018, 1:15:51 PM7/23/18
to joan...@gmail.com, Eve REST Framework
Hi, yes you need "dnspython", you can install using pip. That fixed the problem in my case.

Gabriel Wainer
gab...@tiquetaque.com  
skype: gabrielcw
www.tiquetaque.com

TiqueTaque. Chegamos na hora certa




--
You received this message because you are subscribed to the Google Groups "Eve REST Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-eve+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


A informação contida neste e-mail e em seus anexos é confidencial e não pode ser usada, reproduzida ou divulgada para terceiros que não seu destinatário. Se recebeu este e-mail por equívoco, por favor apague o seu conteúdo e avise o remetente imediatamente.

The information contained in this e-mail and in its attachments is confidential and shall not be used, reproduced or disclosed by any person other than its addressee(s). If received in error, please delete this e-mail's content and contact the sender immediately.

Esta mensagem não tem validade como acordo ou contrato. 

joan...@gmail.com

unread,
Jul 23, 2018, 1:25:30 PM7/23/18
to Eve REST Framework

So I just add it to the requirement.txt in the eve app and pymongo should be happy with that?
with no other change in code in the eve app?

Gabriel Wainer

unread,
Jul 23, 2018, 1:29:09 PM7/23/18
to joan...@gmail.com, Eve REST Framework
yes, that should do it.

Gabriel Wainer
gab...@tiquetaque.com  
skype: gabrielcw
www.tiquetaque.com

TiqueTaque. Chegamos na hora certa


--
You received this message because you are subscribed to the Google Groups "Eve REST Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-eve+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jds...@inmoment.com

unread,
Jul 31, 2018, 5:32:23 PM7/31/18
to Eve REST Framework

So, the dnspython helped fixed that error, but pymongo now throws this error:
pymongo.errors.OperationFailure: Authentication failed.

This is the URI I pass to Eve:
mongodb+srv://username:password@cluster-name/app-db-name?ssl=true&authSource=admin

I can connect to the DB via the shell with no problem.

I do a DB conn check in the eve app which seems to have no issue with the connection:

try:
client = MongoClient(mongoUri)
db = client[mongoDbName]
dbconnStatusJsonString = 'Connection Successful!'
except Exception as e:
dbconnStatusJsonString = 'Please check your connection : ' + str(e) + ' .Actual URI:'+ mongoUri


I am on the latest Eve

Rafał Gliński

unread,
Oct 11, 2022, 4:33:22 AM10/11/22
to Eve REST Framework
Hello All,

The problem is fixed! See https://github.com/pyeve/eve/pull/1482 

Regards
Rafal

Reply all
Reply to author
Forward
0 new messages