How can I create properties (DocDB, Python)?
Hey guys,
I need your help.
I am writing a code in Python and I want to create a database and some properties and then to send json files (data) to this database. (I use client-server-model for loading the data into IRIS)
I use curl methods and convert it in Python code with:
curl.trillworks.com/#python
My code so far:
url = "http://127.0.0.1:52773/api/docdb/v1/NamespaceName/db/DBName" url2 = "http://127.0.0.1:52773/api/docdb/v1/NamespaceName/doc/DBName/" header = { 'Content-Type': 'application/json', } response = requests.get(url, headers=header) print(response.status_code) #Number of error if response.status_code == 404: print('DB not found, create DB ...') response = requests.post(url, headers=header) print(response.status_code) else: print('DB found, load data...')
So I create a Database in the Namespace but all the data is in one column:
I need some properties now, so the data could be parsed.
The curl command for creating a property is:
curl -i -X POST -H "Content-Type: application/json"
propertyName?type= propertyType& path= propertyPath& unique=propertyUnique
and the Python Code should be:
headers = {
'Content-Type': 'application/json\nhttp://127.0.0.1:52773/api/docdb/v1/NamespaceName/db/DBName/\nJahr?type=',
}
response = requests.post('http://Integer&', headers=headers)
Is the code right? And if yes - where should I insert these code in my code? And.. I have more than one properties. How should the code look like?
Thank you in advance