Skip to content

Commit dc84223

Browse files
author
Christopher Rabotin
committed
Adds documentation to from_DSN for v0.8 and v0.9 clients.
1 parent 2130d0f commit dc84223

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

influxdb/client.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,28 @@ def __init__(self,
111111
def from_DSN(dsn, **kwargs):
112112
"""
113113
Returns an instance of InfluxDBClient from the provided data source
114-
name.
114+
name. Supported schemes are "influxdb", "https+influxdb",
115+
"udp+influxdb". Parameters for the InfluxDBClient constructor may be
116+
also be passed to this function.
117+
118+
Examples:
119+
>>> cli = InfluxDBClient.from_DSN('influxdb://username:password@\
120+
... localhost:8086/databasename', timeout=5)
121+
>>> type(cli)
122+
<class 'influxdb.client.InfluxDBClient'>
123+
>>> cli = InfluxDBClient.from_DSN('udp+influxdb://username:pass@\
124+
... localhost:8086/databasename', timeout=5, udp_port=159)
125+
>>> print('{0._baseurl} - {0.use_udp} {0.udp_port}'.format(cli))
126+
http://localhost:8086 - True 159
127+
115128
:param dsn: data source name
116129
:type dsn: string
117130
:param **kwargs: additional parameters for InfluxDBClient.
118131
:type **kwargs: dict
119132
:note: parameters provided in **kwargs may override dsn parameters.
133+
:note: when using "udp+influxdb" the specified port (if any) will be
134+
used for the TCP connection; specify the udp port with the additional
135+
udp_port parameter (cf. examples).
120136
:raise ValueError: if the provided DSN has any unexpected value.
121137
"""
122138
dsn = dsn.lower()

influxdb/influxdb08/client.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,28 @@ def __init__(self,
110110
def from_DSN(dsn, **kwargs):
111111
"""
112112
Returns an instance of InfluxDBClient from the provided data source
113-
name.
113+
name. Supported schemes are "influxdb", "https+influxdb",
114+
"udp+influxdb". Parameters for the InfluxDBClient constructor may be
115+
also be passed to this function.
116+
117+
Examples:
118+
>>> cli = InfluxDBClient.from_DSN('influxdb://username:password@\
119+
... localhost:8086/databasename', timeout=5)
120+
>>> type(cli)
121+
<class 'influxdb.client.InfluxDBClient'>
122+
>>> cli = InfluxDBClient.from_DSN('udp+influxdb://username:pass@\
123+
... localhost:8086/databasename', timeout=5, udp_port=159)
124+
>>> print('{0._baseurl} - {0.use_udp} {0.udp_port}'.format(cli))
125+
http://localhost:8086 - True 159
126+
114127
:param dsn: data source name
115128
:type dsn: string
116129
:param **kwargs: additional parameters for InfluxDBClient.
117130
:type **kwargs: dict
118131
:note: parameters provided in **kwargs may override dsn parameters.
132+
:note: when using "udp+influxdb" the specified port (if any) will be
133+
used for the TCP connection; specify the udp port with the additional
134+
udp_port parameter (cf. examples).
119135
:raise ValueError: if the provided DSN has any unexpected value.
120136
"""
121137
dsn = dsn.lower()

0 commit comments

Comments
 (0)