I have a csv file in a folder that is roughly 500,000 rows long.
Rather than using PHP, I would like to use SH to run a MYSQL LOAD DATA command to load the data in, as I think it would be much faster and would not cause any memory problems associated with PHP.
But the problem is, I am not sure how to combine sh and my MySQL LOAD DATA command as it's on several lines and is very, very long.
The following is a sample of the actual load data I use.
How do I make sh to connect to mysql, and run this following command?
Any help on this would be great!
LOAD DATA LOCAL INFILE '/path/to/traveldata/traveldata.csv'
INTO TABLE `offers`
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 2 LINES
(
OfferProcessType,
TradingName,
OfferLabelDesc,
DestinationName,
DepAirportCode,
TelephoneNumber,
ReturnAirportCode,
ArrivalAirportCode,
ABTA,
ATOL,
OtherBonding,
BoardTypesShort,
AccomodationShort,
AllocationShort,
OperatorShort,
@DepartureDate,
Price,
ShareBasisAdult,
BulkLoaderRef,
Email,
PublicNotes,
CCC,
TOD,
DCC,
AMEX,
CDW,
BookingFee,
AccomodationName,
Duration,
ShareBasisChild,
Rating,
OfferLink,
AccomodationRef,
Transfers,
OperatorsRating,
QuoteRef,
Url,
OutDepTime,
OutArrTime,
InDepTime,
InArrTime
)
SET
DepartureDate = (str_to_date(@DepartureDate, '%d-%M-%y'))
;