Import via .sql file w a auto-increment - TechRepublic
General discussion
March 9, 2004 at 12:41 PM
ericrb

Import via .sql file w a auto-increment

by ericrb . Updated 22 years, 4 months ago

I’m looking for a way to import data from a csv file into MySQL. I’ve found a script that gets me close but the problem I am having a problem with the auto increment field in my table.

The script I’m using simply looks for a file named flatfile.txt and reads it line by line using | as the delimiter and then builds a .sql file with the insert statments. Here’s an example from the .sql file created by the script:

INSERT INTO database_table VALUES (“1″,”1″,”name”,”1″,”description”,”something else”,”100.00″);

The first value corresponds to an auto incrementing field. I suspect i need a different Insert statement or somesort of variable for the value of the auto-increment field. Any ideas??

Thanks,
Eric

This discussion is locked

All Comments