0

I'm looking for the way to import csv file into .sql file which are both in same directory. This is because I don't know the exact path where my project will run on.

it will be in something........./db/migration folder. I tried 'ex.csv', '/ex.csv', './ex.csv', '/db/migration/ex.csv' ..etc.

How can I import it? Or is it impossible?

LOAD DATA INFILE '/ex.csv' INTO TABLE Course
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n'
심시은
  • 269
  • 1
  • 4
  • 18

1 Answers1

1

See the docs: https://dev.mysql.com/doc/refman/8.0/en/load-data.html

The LOCAL modifier affects where the file is expected to be found:

If LOCAL is specified, the file is read by the client program on the client host and sent to the server. The file can be given as a full path name to specify its exact location. If given as a relative path name, the name is interpreted relative to the directory in which the client program was started.

So you should be able to give a relative path the the place where the program was started.

mankowitz
  • 1,602
  • 1
  • 13
  • 27