Hi
Does anybody know how to tranfer data from a comma-separated file to a MySQL database table.
Lars, DK
| SitePoint Sponsor |
Hi
Does anybody know how to tranfer data from a comma-separated file to a MySQL database table.
Lars, DK
Ach. The MySQL I use has a phpAdmin portal.... I'll have a look at the syntax for you.
G
Drupal Development -- Hire me!
Drupal Training | Darwin Awards Moderator | Classic Cars
SitePoint | Blog | Rent Games Online | Car | Talent
Ok. phpAdmin spat out the following SQL when I tested it quickly:
Sub in what you need really. Obviously, INFILE was created by the server temporarily from the CSV, but I'm assuming that INFILE 'http://www.mysite.com/mycsv.csv' would work just the same. Maybe.Code:LOAD DATA LOCAL INFILE '/home/tmp/phpbLAmAj' INTO TABLE test FIELDS TERMINATED BY ', ' ESCAPED BY '\\' LINES TERMINATED BY '\n'![]()
Drupal Development -- Hire me!
Drupal Training | Darwin Awards Moderator | Classic Cars
SitePoint | Blog | Rent Games Online | Car | Talent
Then again, looking at the options, you'd have to change the LOCAL to something I imagine. Still, now you know the basic command you're after you can check the MySQL documentation.![]()
Drupal Development -- Hire me!
Drupal Training | Darwin Awards Moderator | Classic Cars
SitePoint | Blog | Rent Games Online | Car | Talent
Thanks Greg! It works fine.
Lars, DK

http://www.mysql.com/doc/en/LOAD_DATA.html
How do I pass the file from say a form file field to the SQL statement so I can create a page to upload a file from the desktop and insert into MySQL table?
Bookmarks