0

I have to submit geojsons from a Postgres (PostGIS) database with requests.post() method and the files argument:

x = requests.post(url, files = myfiles)

However, I need to avoid writing all my geojsons to a file and then read them again (the cloud environment where the PostsGres is running does not allow me to store files).

I read that a workaround could be to populate the file parameter with a tuple (https://stackoverflow.com/a/23131823/16214039). However, I cannot manage to store my geojson strings into a tuple, since the string will be sliced/splitted due to the '' and comma's in the geojson string when I try to convert it to a tuple element. Any ideas how I can solve this?

2
  • You can use triple quotes """ around the literal if you want to secure all regular single ' and double quotes " inside the string. If that's not what you had in mind, please attach an example where the string in your tuple gets split against your intention. Commented Nov 20, 2023 at 14:02
  • Hi @Zegarek, thanks. Worked! I used triple single quotes and that did not work... But the triple double quotes worked. Commented Nov 20, 2023 at 15:21

0

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.