Skip to content

Commit c9fcede

Browse files
authored
Merge pull request influxdata#393 from eman/fix_dataframe_constructor (Thanks @eman!)
Fix for from_DSN() constructor when using DataFrameClient
2 parents a790a56 + 9812d0f commit c9fcede

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

influxdb/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ def _port(self):
131131
def _get_port(self):
132132
return self.__port
133133

134-
@staticmethod
135-
def from_DSN(dsn, **kwargs):
134+
@classmethod
135+
def from_DSN(cls, dsn, **kwargs):
136136
"""Return an instance of :class:`~.InfluxDBClient` from the provided
137137
data source name. Supported schemes are "influxdb", "https+influxdb"
138138
and "udp+influxdb". Parameters for the :class:`~.InfluxDBClient`
@@ -169,7 +169,7 @@ def from_DSN(dsn, **kwargs):
169169
init_args['port'] = port
170170
init_args.update(kwargs)
171171

172-
return InfluxDBClient(**init_args)
172+
return cls(**init_args)
173173

174174
def switch_database(self, database):
175175
"""Change the client's database.

influxdb/tests/dataframe_client_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,3 +566,8 @@ def test_datetime_to_epoch(self):
566566
cli._datetime_to_epoch(timestamp, time_precision='n'),
567567
1356998400000000000.0
568568
)
569+
570+
def test_dsn_constructor(self):
571+
client = DataFrameClient.from_DSN('influxdb://localhost:8086')
572+
self.assertIsInstance(client, DataFrameClient)
573+
self.assertEqual('http://localhost:8086', client._baseurl)

0 commit comments

Comments
 (0)