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

Commit

Permalink
Merge pull request #393 from eman/fix_dataframe_constructor (Thanks @…
Browse files Browse the repository at this point in the history
…eman!)

Fix for from_DSN() constructor when using DataFrameClient
  • Loading branch information
aviau authored Dec 9, 2016
2 parents a790a56 + 9812d0f commit c9fcede
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
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 @@ -566,3 +566,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)

0 comments on commit c9fcede

Please sign in to comment.