Error when bulk importing line protocol files

Hello,

it’s been a while since i used InfluxDB for the last time. Now, i am lucky enough to join a new activity that uses this wonderful technology.

I understand that something has changed, but i really do not understand why i cannot import data as i always did.

I have a big .txt file:

# DDL
CREATE DATABASE db
CREATE RETENTION POLICY weekly_data ON db DURATION 7d REPLICATION 1

# DML
# CONTEXT−DATABASE: db
# CONTEXT−RETENTION−POLICY: weekly_data

recordings,sensor=s,pp=1,sub_pr=1091,tool=3 value=0.65 330557445980703
recordings,sensor=s,pp=1,sub_pr=1091,tool=3 value=-1.8 330557446058706
recordings,sensor=s,pp=1,sub_pr=1091,tool=3 value=-1.0 330557446136709

and i am trying to import it using the command:

influx -host 192.168.0.0 -import -path=C:\path\line_pr.txt -precision=ns

With my big surprise, i see this error:

error writing batch: {“error”:“database is required”}

Where is the error? I would say that everything is fine, or at least was 2 years ago, when i ran the same command.

Any help is appreciated.

Luca

Hello @luca15f,
What version are you running?

I am currently using last stable version, v1.8.

Any suggestions here? I still cannot solve this issue. I tried to run the same import command from the server itself, but nothing changed.

This seems like a bug to me, I would open a new issue.

You could use Telegraf as a workaround, I recommend using the nightly builds so that you have #7210. You then would need to comment out all the DDL & DML lines since Telegraf doesn’t support them and setup the tail input and the influxdb output.

I agree, this seems a bug to me too, but, anyway, I found a workaround that I am explaining here for any user who is experiencing the same issue.

I read the same tutorial that i followed 2 years ago (you can find it here: https://www.influxdata.com/blog/getting-started-writing-data-to-influxdb/). This webpage is about converting csvs in line protocol files (as I did) and sending them to an influxdb server.

As you can see, the line protocol example (that you can find here: https://github.com/Anaisdg/GettingStarted_WritingPoints/tree/master/Data , at the import.txt file) starts with:

DDL
CREATE DATABASE import

# DML
# CONTEXT-DATABASE: import

that is the very same exact start string I’ve used before and that ended up in the above error (in fact, I tried the import writing no detail on retention policy in both DML and DDL, but again the error showed up).

So I tried the donk way: I literally copied the above preamble and pasted it on top of my line protocol file, and magic happened. Import worked flawlessly.

I don’t know the cause of the issue I’ve encountered. Maybe some special character I used for carriage return, or line feed. I really do not know. I tried to compare both versions of the preamble (the one I produced with the python script and the one I copied from Github page) with Notepad++, and they looked the same.

Hope this helps!

Luca