if myDatabase.exists(): print "'{0}' successfully created.\n".format(databaseName) |
1 2 3 4 5 6 7 | sampleData = [ [1, "one", "boiling", 100], [2, "two", "hot", 40], [3, "three", "warm", 20], [4, "four", "cold", 10], [5, "five", "freezing", 0] ] |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # Create documents by using the sample data. # Go through each row in the array for document in sampleData: # Retrieve the fields in each row. number = document[0] name = document[1] description = document[2] temperature = document[3] # Create a JSON document that represents # all the data in the row. jsonDocument = { "numberField": number, "nameField": name, "descriptionField": description, "temperatureField": temperature } # Create a document by using the database API. newDocument = myDatabase.create_document(jsonDocument) # Check that the document exists in the database. if newDocument.exists(): print "Document '{0}' successfully created.".format(number) |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |