Skip to content

Commit c720f97

Browse files
author
aviau
committed
switch_db -> switch_database
1 parent b231c79 commit c720f97

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

influxdb/client.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ def __init__(self,
101101

102102
# Change member variables
103103

104-
def switch_db(self, database):
104+
def switch_database(self, database):
105105
"""
106-
switch_db()
106+
switch_database()
107107
108108
Change client database.
109109
@@ -112,6 +112,18 @@ def switch_db(self, database):
112112
"""
113113
self._database = database
114114

115+
def switch_db(self, database):
116+
"""
117+
DEPRECATED. Change client database.
118+
119+
"""
120+
warnings.warn(
121+
"switch_db is deprecated, and will be removed "
122+
"in future versions. Please use "
123+
"``InfluxDBClient.switch_database(database)`` instead.",
124+
FutureWarning)
125+
return self.switch_db(database)
126+
115127
def switch_user(self, username, password):
116128
"""
117129
switch_user()

tests/influxdb/client_test.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,14 @@ def test_scheme(self):
8585
)
8686
assert cli._baseurl == 'https://host:8086'
8787

88-
def test_switch_db(self):
88+
def test_switch_database(self):
89+
cli = InfluxDBClient('host', 8086, 'username', 'password', 'database')
90+
cli.switch_database('another_database')
91+
assert cli._database == 'another_database'
92+
93+
@raises(FutureWarning)
94+
def test_switch_db_deprecated(self):
95+
warnings.simplefilter('error', FutureWarning)
8996
cli = InfluxDBClient('host', 8086, 'username', 'password', 'database')
9097
cli.switch_db('another_database')
9198
assert cli._database == 'another_database'

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy