2

I'm trying to import file to Questdb as REST csv upload. My code looks like

import requests
with open('..\data.csv', 'rb') as f:
    r = requests.post('http://localhost:9000/imp?name=weekly3', files={'data.csv': f})
    print(r.text)

However I get back

{"status":"invalid value in 'Content-Disposition' multipart header"}

I do not see anything wrong with Content-Disposition when I dump the request

POST http://localhost:9000/imp?name=weekly3
Content-Length: 197
Content-Type: multipart/form-data; boundary=23ef3f7581b79898155acd5567e0b455
--23ef3f7581b79898155acd5567e0b455
Content-Disposition: form-data; name="data.csv"; filename="data.csv"
C:\Users\allnau\Downloads\data.csv
--23ef3f7581b79898155acd5567e0b455--

1 Answer 1

1

In your files dictionary csv should be under data key.

import requests
with open('..\data.csv', 'rb') as f:
    r = requests.post('http://localhost:9000/imp?name=weekly3', files={'data': f})

As per curl examples, QuestDb accepts data and schema form parts at ?imp endpoint

Sign up to request clarification or add additional context in comments.

1 Comment

It should be a r'...' string for the path, and the POST should announce the file's encoding.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.