Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Fix for from_DSN() constructor when using DataFrameClient #393

Merged
merged 2 commits into from
Dec 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions influxdb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ def _port(self):
def _get_port(self):
return self.__port

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

return InfluxDBClient(**init_args)
return cls(**init_args)

def switch_database(self, database):
"""Change the client's database.
Expand Down
5 changes: 5 additions & 0 deletions influxdb/tests/dataframe_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,3 +553,8 @@ def test_datetime_to_epoch(self):
cli._datetime_to_epoch(timestamp, time_precision='n'),
1356998400000000000.0
)

def test_dsn_constructor(self):
client = DataFrameClient.from_DSN('influxdb://localhost:8086')
self.assertIsInstance(client, DataFrameClient)
self.assertEqual('http://localhost:8086', client._baseurl)