Skip to content

Commit 265d147

Browse files
bafteksebito91
authored andcommitted
Data arg in write() can be single string (influxdata#492)
* data arg in write() can be single string data argument in write() was expected to be list of strings, now it can be single string as well * Fix linter error * Trailing whitespace removed * Transformed to isinstance instead of using type() * Change list(str) to [str]
1 parent e07dafc commit 265d147

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

influxdb/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ def write(self, data, params=None, expected_response_code=204,
271271
:param data: the data to be written
272272
:type data: (if protocol is 'json') dict
273273
(if protocol is 'line') sequence of line protocol strings
274+
or single string
274275
:param params: additional parameters for the request, defaults to None
275276
:type params: dict
276277
:param expected_response_code: the expected response code of the write
@@ -292,6 +293,8 @@ def write(self, data, params=None, expected_response_code=204,
292293
if protocol == 'json':
293294
data = make_lines(data, precision).encode('utf-8')
294295
elif protocol == 'line':
296+
if isinstance(data, str):
297+
data = [data]
295298
data = ('\n'.join(data) + '\n').encode('utf-8')
296299

297300
self.request(

0 commit comments

Comments
 (0)