Using CF to convert the file into an INSERT statement would be quite slow,
I'd imagine, though you could probably restore some of the performance by
buffering (using a StringBuffer, for example).

LOAD DATA INFILE is going to be as fast as you can do it.  I've never used
it for more than a few thousand records, but it was blazing fast, and all
the load is on the DB (not CF), which is very nice.  I'm not going to say
that it won't be a burden on the server, but it'll be relatively small for
that many records.

And if you're replacing the all the data (as opposed to adding new data),
make sure you use TRUNCATE TABLE rather than DELETE.  It drops and recreates
the table, rather than deleting each row, so it's enormously faster when
you've got a big table and you need to delete all the rows.

Cheers,
barneyb

> -----Original Message-----
> From: Mickael [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, April 13, 2004 12:32 PM
> To: CF-Talk
> Subject: Re: Import a Text file to MYSQL
>
> Hi Barney,
>
> I have over 1 million records to import daily would that not
> be very taxing on the server?
>   ----- Original Message -----
>   From: Barney Boisvert
>   To: CF-Talk
>   Sent: Tuesday, April 13, 2004 3:16 PM
>   Subject: RE: Import a Text file to MYSQL
>
>
>   You can use LOAD DATA INFILE if you have sufficient
> privileges on the server
>   and the file format is acceptable.  If not, it's pretty
> simple to do some
>   text manipulation and convert text into a multi-line INSERT
> statement:
>
>   INSERT INTO tabl
>   (col1, col2, col3)
>   VALUES
>   ('11', '12', '13'),
>   ('21', '22', '23'),
>   ('31', '32', '33'),
>   .....
>   ('n1', 'n2', 'n3)
>
>   Basically, it goes like this: replace all "'" with "\'",
> add "('" to the
>   start of every line, add "')" to the end, replace "," with
> "','", prepend
>   the INSERT .... VALUES stuff, and then remove the trailing comma.
>
>   Cheers,
>   barneyb
>
>   > -----Original Message-----
>   > From: Mickael [mailto:[EMAIL PROTECTED]
>   > Sent: Tuesday, April 13, 2004 12:06 PM
>   > To: CF-Talk
>   > Subject: Import a Text file to MYSQL
>   >
>   > Hello All,
>   >
>   > Can you import a text file to MYSQL with CF.  I would like to
>   > take a text file that is exported to Access then Drop/Create
>   > the table with CF in MYSQL then import the file in its
>   > entirety to create the table.
>   >
>   > This sounds simple enough in theory, how can this be done in
>   > CF and MYSQL I don't really have any experience with MYSQL
>   >
>   > Thanks in advance
>   >
>   > Mike
>   >
>   >
>   >
>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to