Not able to connect to cloudant DB from python code

Hi There,

I am not able to connect to Cloudant DB which I created in Watson IoT platform.

I am running the below code to connect to cloudant DB from python which I referred from [here][1]:

from cloudant.client import Cloudant

serviceUsername = “3e80881e-8b4f-4a92-8aed-bfcd1c7536af-bluemix”
servicePassword = “49c0c343d225623956157d94b25d574586f26d1211e8e589646b4713d5de4801”
serviceURL = “https://353466e8-47eb-45ce-b125-4a4e1b5a4f7e-bluemix.cloudant.com”

client = Cloudant(serviceUsername, servicePassword, url=serviceURL)
client.connect()
databaseName = “databasedemo”
myDatabaseDemo = client.create_database(databaseName)

But I am getting the below error on the line client.connect() :

requests.exceptions.ConnectionError: HTTPSConnectionPool(host=’3e80881e-8b4f-4a92-8aed-bfcd1c7536af-bluemix.cloudant.com’, port=443): Max retries exceeded with url: /_session (Caused by NewConnectionError(‘: Failed to establish a new connection: [Errno -2] Name or service not known’,))

and some times the line client.connect() executes but fail on further operation and when I print the ‘client’ then I get ‘{}’ means connection is not getting created.

I don’t know how to make use of ‘VCAP SERVICES’ and even I don’t like to go with that way.

Please help me out I am stuck here.
Thanks in advance.

[1]: https://console.ng.bluemix.net/docs/services/Cloudant/tutorials/create_database.html#creating-and-populating-a-simple-cloudant-database-on-bluemix

Related:

Leave a Reply