Jump to content

Php + Mysql - Is There An Alternative To Load Data Infile?


willothewisp

Recommended Posts

Hi,

 

I've written a website which downloads a large CSV file from a trusted affiliate marketing source (once every 24 hours, using a Cron script), then puts the content of the CSV file into a products table in a MySQL database. The CSV file consists of 50,000 - 100,000 products.

As the CSV file is so large, I've written the script to use MYSQL command LOAD DATA LOCAL INFILE, which should automatically read the CSV file and import it into the products table for me. I've got it working locally, but not on the production server.

At first I couldn't understand why it wouldn't work, then my hosting company told me that as a matter of company policy, they didn't allow load data local infile statements.

I asked them for alternatives and so far, they've come up with nothing.

 

One obvious alternative would be to read the CSV file and iterate through it line by line, creating an SQL Insert statement for every line. But I'd imagine that would be very slow, and with 50 - 100,000 products, put an enormous load on the server.

 

Does anyone know of an alternative method that I could use to read in this large file? Or alternatively, a hosting company that will let me use load data local infile?

 

Thanks!

Link to comment
Share on other sites

You can insert multiple lines in a single query, using a php script to build the query and execute it. Although it will be more taxing on the server, as you say. As for alternatives, it all depends on how much you are willing to spend for your hosing, Rackspace is a premium provider here in the UK, but the service is second to none.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.