File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -131,8 +131,8 @@ def _port(self):
131
131
def _get_port (self ):
132
132
return self .__port
133
133
134
- @staticmethod
135
- def from_DSN (dsn , ** kwargs ):
134
+ @classmethod
135
+ def from_DSN (cls , dsn , ** kwargs ):
136
136
"""Return an instance of :class:`~.InfluxDBClient` from the provided
137
137
data source name. Supported schemes are "influxdb", "https+influxdb"
138
138
and "udp+influxdb". Parameters for the :class:`~.InfluxDBClient`
@@ -169,7 +169,7 @@ def from_DSN(dsn, **kwargs):
169
169
init_args ['port' ] = port
170
170
init_args .update (kwargs )
171
171
172
- return InfluxDBClient (** init_args )
172
+ return cls (** init_args )
173
173
174
174
def switch_database (self , database ):
175
175
"""Change the client's database.
Original file line number Diff line number Diff line change @@ -566,3 +566,8 @@ def test_datetime_to_epoch(self):
566
566
cli ._datetime_to_epoch (timestamp , time_precision = 'n' ),
567
567
1356998400000000000.0
568
568
)
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 )
You can’t perform that action at this time.
0 commit comments