cloudant / python-cloudant

A Python library for Cloudant and CouchDB
Apache License 2.0
163 stars 55 forks source link

HTTP Error 404 #446

Closed DanMan259 closed 5 years ago

DanMan259 commented 5 years ago

Please read these guidelines before opening an issue.

Bug Description

Keep getting HTTP Error 404 when trying to populate an instance. I have looked into a similar issue posted but I didn't seem to get a solution out of the issue post.

1. Steps to reproduce and the simplest code sample possible to demonstrate the issue

Here is a simplified version of my code

from datetime import datetime, date, timedelta
from cloudant.client import Cloudant
from cloudant.document import Document
import json

# Connect with Cloudant
client = Cloudant(USERNAME, PASSWORD, url=URL, connect = True, auto_renew = True)
dayData =[{'Date/Time': '2019-05-01 00:00', 'Temp (°C)': 4.0, 'Dew Point Temp (°C)': -7.1}, 
  {'Date/Time': '2019-05-01 01:00', 'Temp (°C)': 4.3, 'Dew Point Temp (°C)': -8.2}] 
#Just a way to get a date in dbName
dbName = "weatherData_"+str(datetime.strptime(dayData[0]['Date/Time'],'%Y-%m-%d %H:%M').date())
db = client.create_database(dbName)
time.sleep(0.2)
# for each of the values in the dayData list upload as document
for i in range(len(dayData)):
    with Document(db, dayData[0]['Date/Time'] ) as document:
        # The JSON String is posted in Data
        document["data"] = json.dumps(dayData[i])
        time.sleep(0.2)

2. What you expected to happen

This is a simplified version of my code that is suppose to create a database named after a specific date, and then uses that created database and uploads a data string to it.

3. What actually happened

I keep on getting this error.

HTTPError: 404 Client Error: Object Not Found not_found Database does not exist. for url: https://####-####.cloudantnosqldb.appdomain.cloud/weatherData_2019-05-01

Ive tested all the logic in my original code, and works if i set the name to a something but if i have a dynamic name I keep getting the same error. I even put in time.sleep for request limiting

Environment details