5
I’m trying to do the following, I have this connection to Influxdb:
InfluxDBClient('localhost', 8086, 'root', 'root', 'example')
But I want to turn these parameters into a constant, so I don’t have to keep changing the code every time I change.
At first I thought to create for each parameter:
INFLUXDB_HOST = 'influxdb'
INFLUXDB_PORT = 8086
INFLUXDB_USERNAME = 'root'
INFLUXDB_PASSWORD = 'root'
INFLUXDB_DATABASE = 'example'
But does it have a way to join all these variables within one and pass straight into the function?
InfluxDBClient(MINHAS_VARIAVEIS)
Influx is not the problem itself, the same case would be for the example below.
In [1]: def conta(a, b, c):
...: print(a,b,c)
...:
In [2]: conta(1,2,3)
(1, 2, 3)
In [3]: teste = (1,2,3)
In [4]: conta(teste)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-5feac543a26b> in <module>()
----> 1 conta(teste)
TypeError: conta() takes exactly 3 arguments (1 given)
In [5]:
In case I would not change inside the function (because in Influx there is no way).
The function
InfluxDBClient
is yours? You can change?– Costamilam
No, the only constraint is not changing the function, otherwise I would make a tuple or list.
– Vinicius Morais