When I import a CSV file I get this error:

(table name) has no primary key defined. A single-field primary key is necessary to use this table as the base table for a view.

I need a way to set up my CSV file to have a primary key that will be recognized by Table Wizard. The CSV file I am using was never exported from any SQL database. I just want to import data from a CSV that I make myself, and then automatically populate CCK fields with that data using the Migrate module. The first step, of course, is to import the data from a CSV using Table Wizard.

I have been all over drupal.org and the rest of the web to find out how to put primary key information into a CSV file. No luck.

I am not well versed in databases, so please humour me if I'm being dumb or not getting some fundamental MySQL concept here...

Thanks,
Adam

Comments

thermador’s picture

OK I figured it out, just by random chance really. I realized that when you upload a CSV file to Table Wizard, it immediately creates a new table in the database. I didn't realize that it did this. I went into PHPMyAdmin, redefined the column of data I wanted to use as a primary key from longtext to int, and also as not null. Then I made it a primary key, and now I'm in business...

I know programmers/coders hate to write documentation because they are simply too 1337 for it, but good god, this could have been easy if there was good, current documentation for this module & the migrate module.

mikeryan’s picture

Component: User interface » Documentation
Status: Active » Fixed

This was addressed in RC1, adding the relevant information to the message you receive when you upload a file:

comments.txt has been imported into new table aaaa. All fields have initially been defined as text, with no indexing - it is important to use your database management software to set appropriate data types for each field, and to define a single (unique, non-null) field as the primary key. After you have done this, reanalyze the table.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.