Open connde opened 5 years ago
What version of the client and server are you using? I can insert DF into influxDB 1.3.5 with client 4.1.1 using tags. I'm facing troubles with versions 1.6.1 / 5.2.0. But provided that you stay in 1.3.5 / 4.1.1, it should work nicely ...
See this for an example: https://github.com/influxdata/influxdb-python/issues/629
I have 1.6.1 / 5.2.0.
Have you tried downgrading only the python package to see if it worked?
Hi, I'm trying to use DataFrameClient to store data into Influx, I managed to insert the data into the database, but I cannot set any tags, so I'm able to insert if I don't set a tag.
Could someone help me out? I'm sure is something simple, but since I'm new to influx I'm not being able to solve it.
I want to store currency prices (open, close, high, low, volume) data related to a symbol. I'm working with minute candles.
So basically I consume an API that return a json, after I have it on the dataframe I set the types of each column. I also clean the dataframe and eliminate possible duplications.
This works, but without tags
influx.write_points(dataframe=df, database=dbname, protocol=protocol, time_precision='m', measurement="test")
I'm creating the tag like that as I saw some samples in the internettags = {'symbol': df[['symbol']]}
So if I do like that I will get an error
influx.write_points(dataframe=df, database=dbname, protocol=protocol, time_precision='m', measurement="test", tag_columns=tags)
Traceback (most recent call last): File "c:\Workspace\algo-trading\bitmex\testInflux.py", line 61, in
influx.write_points(dataframe=df, database=dbname, protocol=protocol, time_precision='m', measurement="test", tag_columns=tags, field_columns=columns)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\influxdb_dataframe_client.py", line 131, in write_points
field_columns=field_columns)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\influxdb_dataframe_client.py", line 264, in _convert_dataframe_to_json
dataframe[tag_columns].to_dict('record'),
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\pandas\core\frame.py", line 2688, in getitem
return self._getitem_column(key)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\pandas\core\frame.py", line 2695, in _getitem_column
return self._get_item_cache(key)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\pandas\core\generic.py", line 2487, in _get_item_cache
res = cache.get(item)
TypeError: unhashable type: 'dict'
So I think I need to add field_columns also, tried both combinations with same above message
So now I try using tags param
influx.write_points(dataframe=df, database=dbname, protocol=protocol, time_precision='m', measurement="test", tags=tags)
This is the error I get
Traceback (most recent call last): File "c:\Workspace\algo-trading\bitmex\testInflux.py", line 61, in
influx.write_points(dataframe=df, database=dbname, protocol=protocol, time_precision='m', measurement="test", tags=tags)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\influxdb_dataframe_client.py", line 138, in write_points
protocol=protocol)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\influxdb\client.py", line 490, in write_points
tags=tags, protocol=protocol)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\influxdb\client.py", line 551, in _write_points
protocol=protocol
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\influxdb\client.py", line 327, in write
headers=headers
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\influxdb\client.py", line 286, in request
raise InfluxDBClientError(response.content, response.status_code)
influxdb.exceptions.InfluxDBClientError: 400: {"error":"partial write: unable to parse 'test,symbol=\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ symbol': missing fields\nunable to parse 'timestamp\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ': missing fields\nunable to parse '2017-01-01\ 00:00:00\ \ XBTUSD': missing fields\nunable to parse
'2017-01-01\ 00:01:00\ \ XBTUSD': missing fields\nunable to parse '2017-01-01\ 00:02:00\ \ XBTUSD': missing fields\nunable to parse '2017-01-01\ 00:03:00\ \ XBTUSD': missing fields\nunable to parse '2017-01-01\ 00:04:00\ \
Sample when inserting without tags
Also, is this how I should insert this type of information? index: timestamp tags: symbol fields: close, high, low, open, trades, volume