Re: Using LOAD DATA INFILE with byte stream
Posted by: Mark Matthews
Date: November 30, 2005 08:30PM
Mark Matthews wrote:
> Carlo Bos wrote:
> > Can you please help me with the following
> > problem:
> > I'm currently looking at the LOAD DATA
> > statement to load a csv file into a table.
> > statement requires a filename and the
> database to
> > access this file on the filesystem. (I've
> > this statement successfully on my
> > machine)
> > However in the production environment, the
> > file is received through a web form on a
> > 4.0.2 server and the MySQL 4.1 server resides
> on a
> > different machine.
> > So to solve this issue I'm wondering if there
> > way to specify a byte stream through a jdbc
> > connection to accomplish this. Meaning that
> > uploaded file does not need to be created on
> > server, but is directly streamed to the
> > I'd really like to use the automatic parsing
> > ability that comes with the LOAD DATA INFILE
> > command though. Any solution is welcome!
> > So in short: I'd like an uploaded csv file to
> > imported to a MySQL table which resides on a
> > different machine than the web app server.
> > Code examples are appreciated.
> > Thanks,
> > Carlo
> Carlo, there isn't directly support for it, as
> there's no easy way to specify the stream file
> descriptor in SQL. However, if you add
> "allowUrlInLocalInfile=true" to your JDBC URL, the
> "path" to LOAD DATA INFILE LOCAL can be a URL,
> which could be made to wrap your input stream in
> some way.
> You could also always hack something into
> MySQLIO.sendFileToServer() to grab a stream from a
> thread local, since we don't currently have plans
> for adding this functionality ourselves (at least
> until we figure out a nice way to do it).
Ah, also noticed that you weren't using LOAD DATA LOCAL INFILE, which would work without any "hacks", since you could have the file "local" to the JDBC driver. The JDBC driver then streams this file to the MySQL server.
Consulting Member Technical Staff - MySQL Enterprise Tools
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.