2

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

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
MattDMo
  • 90,104
  • 20
  • 213
  • 210
  • can you provide the tablestructure and example input? For the second part of your question, have a look at creating cronjobs in php. http://stackoverflow.com/questions/4421020/use-php-to-create-edit-and-delete-crontab-jobs –  Oct 14 '13 at 13:46
  • i've added the sql input to the original question and will take a look at the cron job post. Cheers :) – user2879048 Oct 14 '13 at 20:15

1 Answers1

0

I would recommend a cron job to automate the process, and probably use BCP (bulk copy) to insert the data into a table... But seeing as you are using MySQL, instead of BCP, try load data in file - https://mariadb.com/kb/en/load-data-infile/

thebumblecat
  • 141
  • 1
  • 8