1
1
# -*- coding: utf-8 -*-
2
2
"""
3
- python client for influxdb
3
+ Python client for InfluxDB
4
4
"""
5
5
import json
6
6
import socket
@@ -18,8 +18,31 @@ def __init__(self, content, code):
18
18
19
19
20
20
class InfluxDBClient (object ):
21
+
21
22
"""
22
- InfluxDB Client
23
+ The ``InfluxDBClient`` object holds information necessary to connect
24
+ to InfluxDB. Requests can be made to InfluxDB directly through the client.
25
+
26
+ :param host: hostname to connect to InfluxDB, defaults to 'localhost'
27
+ :type host: string
28
+ :param port: port to connect to InfluxDB, defaults to 'localhost'
29
+ :type port: int
30
+ :param username: user to connect, defaults to 'root'
31
+ :type username: string
32
+ :param password: password of the user, defaults to 'root'
33
+ :type password: string
34
+ :param database: database name to connect to, defaults is None
35
+ :type database: string
36
+ :param ssl: use https instead of http to connect to InfluxDB, defaults is False
37
+ :type ssl: boolean
38
+ :param verify_ssl: verify SSL certificates for HTTPS requests, defaults is False
39
+ :type verify_ssl: boolean
40
+ :param timeout: number of seconds Requests will wait for your client to establish a connection, defaults to None
41
+ :type timeout: int
42
+ :param use_udp: use UDP to connect to InfluxDB, defaults is False
43
+ :type use_udp: int
44
+ :param udp_port: UDP port to connect to InfluxDB, defaults is 4444
45
+ :type udp_port: int
23
46
"""
24
47
25
48
def __init__ (self ,
@@ -34,7 +57,7 @@ def __init__(self,
34
57
use_udp = False ,
35
58
udp_port = 4444 ):
36
59
"""
37
- Initialize client
60
+ Construct a new InfluxDBClient object.
38
61
"""
39
62
self ._host = host
40
63
self ._port = port
@@ -68,22 +91,25 @@ def __init__(self,
68
91
69
92
def switch_db (self , database ):
70
93
"""
71
- Change client database
94
+ switch_db()
95
+
96
+ Change client database.
72
97
73
- Parameters
74
- ----------
75
- database : string
98
+ :param database: the new database name to switch to
99
+ :type database: string
76
100
"""
77
101
self ._database = database
78
102
79
103
def switch_user (self , username , password ):
80
104
"""
81
- Change client username
105
+ switch_user()
82
106
83
- Parameters
84
- ----------
85
- username : string
86
- password : string
107
+ Change client username.
108
+
109
+ :param username: the new username to switch to
110
+ :type username: string
111
+ :param password: the new password to switch to
112
+ :type password: string
87
113
"""
88
114
self ._username = username
89
115
self ._password = password
@@ -131,14 +157,13 @@ def request(self, url, method='GET', params=None, data=None,
131
157
132
158
def write_points (self , * args , ** kwargs ):
133
159
"""
134
- Write to multiple time series names
160
+ write_points()
135
161
136
- Parameters
137
- ----------
138
- batch_size : Optional. Int value to write the points in batches instead
139
- of all at one time.
140
- Useful for when doing data dumps from one database to another or
141
- when doing a massive write operation
162
+ Write to multiple time series names.
163
+
164
+ :param batch_size: [Optional] Value to write the points in batches instead of all at one time.
165
+ Useful for when doing data dumps from one database to another or when doing a massive write operation
166
+ :type batch_size: int
142
167
"""
143
168
144
169
def list_chunks (l , n ):
@@ -300,12 +325,13 @@ def query(self, query, time_precision='s', chunked=False):
300
325
301
326
def create_database (self , database ):
302
327
"""
303
- Create a database
328
+ create_database()
329
+
330
+ Create a database on the InfluxDB server.
304
331
305
- Parameters
306
- ----------
307
- database: string
308
- database name
332
+ :param database: the name of the database to create
333
+ :type database: string
334
+ :rtype: boolean
309
335
"""
310
336
url = "db"
311
337
@@ -322,12 +348,13 @@ def create_database(self, database):
322
348
323
349
def delete_database (self , database ):
324
350
"""
325
- Drop a database
351
+ delete_database()
326
352
327
- Parameters
328
- ----------
329
- database: string
330
- database name
353
+ Drop a database on the InfluxDB server.
354
+
355
+ :param database: the name of the database to delete
356
+ :type database: string
357
+ :rtype: boolean
331
358
"""
332
359
url = "db/{0}" .format (database )
333
360
@@ -358,12 +385,13 @@ def get_database_list(self):
358
385
359
386
def delete_series (self , series ):
360
387
"""
361
- Drop a series
388
+ delete_series()
389
+
390
+ Drop a series on the InfluxDB server.
362
391
363
- Parameters
364
- ----------
365
- series: string
366
- series name
392
+ :param series: the name of the series to delete
393
+ :type series: string
394
+ :rtype: boolean
367
395
"""
368
396
url = "db/{0}/series/{1}" .format (
369
397
self ._database ,
0 commit comments