General discussion

Locked

Import via .sql file w a auto-increment

By EricRB ·
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 conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by sgt_shultz In reply to Import via .sql file w a ...

well, you won't need to insert anything into the autoincrement field, it will, well, autoincrement...

Collapse -

by EricRB In reply to

Poster rated this answer.

Collapse -

by ziqbalbh In reply to Import via .sql file w a ...

You don't need to specify any value for autoincrement fields. Just omit that field and specify column names explicity, so that they could correspond with the values.

Collapse -

by EricRB In reply to

Poster rated this answer.

Collapse -

by EricRB In reply to Import via .sql file w a ...

Thanks for the suggestions. The answer (for my case at least)was to enter NULL as the value for the auto increment value. Worked great.

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums