Hi Alex, It is true that use LOAD DATA INFILE you do need to know the schema of the table. I'm not sure how useful it would be to import arbitrary data if you don't have some expectations about what that data is. There are a couple options for you:
1. Make sure your users upload a CSV is a specific format, reject non-conforming input. 2. Let your script transform the user uploaded CSV file into the format the database is expecting. 3. Have your script simply parse the user uploaded CSV and generate insert statements as needed. Just because you want to accept CSV from your app, does not mean you must use LOAD DATA INFILE to get the data into MySQL. Regards, Gavin Towey -----Original Message----- From: alex.ksi...@gmail.com [mailto:alex.ksi...@gmail.com] On Behalf Of Alex K Sent: Tuesday, May 19, 2009 5:43 AM To: MySQL General List Subject: Re: load data into temporary table Thank you but the real problem occurs when you don't know the schema of the table in advance. If data.txt has two columns columns how can I still load it in a temporary table? I'm asking this question because I'd like to add an import csv feature to a web application. I know that you can load data infile into table without specifying the schema of this table but it does not look like you can do load data infile into a temporary table. Thank you, Alex 2009/5/19 Janek Bogucki <janek.bogu...@studylink.com>: > Hi, > > mysql> create temporary table t(i int); > > mysql> \! echo 1 > /tmp/data.txt > > mysql> load data infile '/tmp/data.txt' into table t; > Query OK, 1 row affected (0.00 sec) > Records: 1 Deleted: 0 Skipped: 0 Warnings: 0 > > mysql> select * from t; > +------+ > | i | > +------+ > | 1 | > +------+ > 1 row in set (0.00 sec) > > Best Regards, > -Janek, CMDEV 5.0. > StudyLink. Helping People Realise Their Potential. > http://studylink.com > > > On Tue, 2009-05-19 at 02:57 +0100, Alex K wrote: >> Hello, >> >> Would anyone know how to load data infile into a temporary table? >> >> Thank you, >> >> Alex >> > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/mysql?unsub=alex.ksi...@gmail.com > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=gto...@ffn.com The information contained in this transmission may contain privileged and confidential information. It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=arch...@jab.org