1
from cloudant.client import Cloudant
from cloudant.error import CloudantException
from cloudant.result import Result, ResultByKey

client = Cloudant("23000-xxx-yyy-0000-b9111111b-bluemix", 
    "axx483d9xxxxxxxxx290ab34xx7a5421b3500f6c0002acfd", 
    url="https://23000-xxx-yyy-0000-b9111111b-bluemix:axx483d9xxxxxxxxx290ab34xx7a5421b3500f6c0002acfd@2374770e-6e45-45a7-91ba-b9214865a81b-bluemix.cloudantnosqldb.appdomain.cloud")

client.connect()

database_name = "Translation_DB"

my_database = client.create_database(database_name)

this code is not connecting to the cloud database I am trying to connect from my local pc to the db in cloud

data_henrik
  • 16,724
  • 2
  • 28
  • 49

1 Answers1

0

The reason for the non-creation of the database in Cloudant NoSQL DB service on IBM Cloud is the Cloudant database name. If you read the note carefully, only lower characters are allowed in the database name.

The database name must begin with a letter and can include only lowercase characters (a-z), numerals (0-9), and any of the following characters _, $, (, ), +, -, and /.

Using translation_db as the database_name should work as expected.

To see the success message in the output, add the below code snippet

if my_database.exists():
    print(f"'{database_name}' successfully created.")
Vidyasagar Machupalli
  • 2,737
  • 1
  • 19
  • 29