0

I need to create a file using NamedTemporaryFile and download some data into it:

 f = NamedTemporaryFile(suffix='.csv', delete=False)
 s3.download_fileobj(bucket, f"{files_dir}/metadata/{table_name}.csv.gz", f)

After that I need to load data into mysql table using LOAD DATA INFILE But I get an error:

File '/tmp/tmp00f3funu.csv' not found (OS errno 13 - Permission denied)

I suppose mysql root user doesn't have enough permissions to read temp file. This temp file has permissions to read only for owner of this file. What should I do to resolve this issue?

Vlad Aleshin
  • 361
  • 4
  • 15

1 Answers1

0

here you either need to run as SQL user, which might not be the best idea

or just change file permissions after file is created using os.chmod see detailed answer here: https://stackoverflow.com/a/16249655/7453765

Beliaev Maksim
  • 968
  • 12
  • 21