@@ -18,6 +18,8 @@ Please take a moment to review the following client docs:
18
18
- [ Initializing Client] ( #initializing-client )
19
19
- [ Creating Database/Bucket] ( #creating-databasebucket )
20
20
- [ Dropping Database/Bucket] ( #dropping-databasebucket )
21
+ - [ Writing LineProtocol] ( #writing-lineprotocol )
22
+ - [ Writing Dictionary-style object] ( #writing-dictionary-style-object )
21
23
22
24
## Initializing Client
23
25
@@ -118,16 +120,63 @@ with InfluxDBClient(url='http://localhost:8086', token='my-token', org='my-org')
118
120
write_api.write(bucket = ' my-bucket' , record = ' h2o_feet,location=coyote_creek water_level=1.0 1' )
119
121
```
120
122
121
- ## Writing Point Object
123
+ ## Writing Dictionary-style object
122
124
123
125
** influxdb-python**
124
126
125
127
``` python
128
+ from influxdb import InfluxDBClient
129
+
130
+ record = [
131
+ {
132
+ " measurement" : " cpu_load_short" ,
133
+ " tags" : {
134
+ " host" : " server01" ,
135
+ " region" : " us-west"
136
+ },
137
+ " time" : " 2009-11-10T23:00:00Z" ,
138
+ " fields" : {
139
+ " Float_value" : 0.64 ,
140
+ " Int_value" : 3 ,
141
+ " String_value" : " Text" ,
142
+ " Bool_value" : True
143
+ }
144
+ }
145
+ ]
146
+
147
+ client = InfluxDBClient(host = ' 127.0.0.1' , port = 8086 , username = ' root' , password = ' root' , database = ' dbname' )
148
+
149
+ client.write_points(record)
126
150
```
127
151
128
152
** influxdb-client-python**
129
153
130
154
``` python
155
+ from influxdb_client import InfluxDBClient
156
+ from influxdb_client.client.write_api import SYNCHRONOUS
157
+
158
+ with InfluxDBClient(url = ' http://localhost:8086' , token = ' my-token' , org = ' my-org' ) as client:
159
+ write_api = client.write_api(write_options = SYNCHRONOUS )
160
+
161
+ record = [
162
+ {
163
+ " measurement" : " cpu_load_short" ,
164
+ " tags" : {
165
+ " host" : " server01" ,
166
+ " region" : " us-west"
167
+ },
168
+ " time" : " 2009-11-10T23:00:00Z" ,
169
+ " fields" : {
170
+ " Float_value" : 0.64 ,
171
+ " Int_value" : 3 ,
172
+ " String_value" : " Text" ,
173
+ " Bool_value" : True
174
+ }
175
+ }
176
+ ]
177
+
178
+ write_api.write(bucket = ' my-bucket' , record = record)
179
+
131
180
```
132
181
133
182
## Writing Structured Data
0 commit comments