Replace contents of MySQL table with contents of csv file on a remote server

I’m a newbie here trying to import some data into my wordpress database (MySQL) and I wonder if any of you SQL experts out there can help?

Database type: MySQL

Read More

Table name: wp_loans

I would like to completely replace the data in table wp_loans with the contents of file xyz.csv located on a remote server, for example https://www.mystagingserver.com/xyz.csv

All existing data in the table should be replaced with the contents of the CSV file.

The 1st row of the CSV file is the table headings so can be ignored.

I’d also like to automate the script to run daily at say 01:00 in the morning if possible.

UPDATE

Here is the SQL I’m using to try and replace the table contents:

LOAD DATA INFILE 'https://www.mystagingserver.com/xyz.csv'
REPLACE
INTO TABLE wp_loans

FIELDS TERMINATED BY ','
  ENCLOSED BY '"'

IGNORE 1 LINES

Related posts

Leave a Reply

1 comment