in reply to Re^2: DBI question
in thread DBI question

While you could either take the lump approach I've taken above or execute a single CREATE TABLE command followed by a series of ALTER TABLE ... ADD statements is fairly irrelevant from an algorithmic perspective. Both require that you specify the data type at run time. I would suggest using a hash to specify your desired types, and interpolate these into the appropriate SQL statements. Another possibility is a simple if-else clause.

It sounds like you have a specific file and set of column names in mind - if this is the case, wouldn't it be easier to just craft the SQL rather than trying to do all this autodiscovery?

Replies are listed 'Best First'.
Re^4: DBI question
by gogoglou (Beadle) on Jun 24, 2010 at 07:46 UTC
    well the problem is that it not exacytly a specific set of columns. I havea series of tab delimited files, where usually some of the columns differ, that is the reason why I want to create the database depending on the file. Of coyurse it would be much easier to just craft the SQL, but it would be really helpfull if I could automate the procedure. Again thank you very much for your suggestions!

      If the TSV file has a header, why not use DBD::CSV to access it?


      Enjoy, Have FUN! H.Merijn