influxdb-python
influxdb-python copied to clipboard
`client.switch_database('db_name')` works, despite database not existing
- InfluxDB version: '1.7.8'
- InfluxDB-python version: 5.2.3
- Python version: 3.7.7
- Operating system version: Ubuntu 18.04.3 LTS
when I initialize a client like so:
client = InfluxDBClient(host=host, port=port, username=username, password=password)
and then, if I want to write to a particular database, I would do:
client.switch_database('some_db_name').
If some_db_name does not exist in client.get_list_database() I don't get any error.
Also, a new db is not created either. It feels that it should at least give an early warning if not an error.
In addition:
- When I create a database that already exists, nothing happens (no warning or error). Therefore the question is, did it do nothing or did it create (overwrite) an existing one?
- It will be nice to have a function to show which database is the client currently on. There is no way of knowing currently (only via accessing the protected
client._database.
@snenkov thanks for the issue:
It looks like switch_database doesn't run any command against Influx: https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/client.py#L173
- This is the behavior of InfluxDB: https://docs.influxdata.com/influxdb/v1.7/query_language/database_management/#create-database
- Feels like a very easy function to add to the client.py above. Would you like to take a crack at it?