[erlang-questions] importing sql data

Joe Armstrong erlang@REDACTED
Wed Mar 4 15:54:23 CET 2009


I have a file, which if run into sql builds a data base.

It starts like this:

# For updates to this file, see http://27.org/isocountrylist/
# Created by getisocountrylist.pl on Sun Nov  2 14:59:20 2003.
# Wm. Rhodes <iso_country_list@REDACTED>

CREATE TABLE IF NOT EXISTS country (
  iso CHAR(2) NOT NULL PRIMARY KEY,
  name VARCHAR(80) NOT NULL,
  printable_name VARCHAR(80) NOT NULL,
  iso3 CHAR(3),
  numcode SMALLINT
);

INSERT INTO country VALUES ('AF','AFGHANISTAN','Afghanistan','AFG','004');
INSERT INTO country VALUES ('AL','ALBANIA','Albania','ALB','008');
INSERT INTO country VALUES ('DZ','ALGERIA','Algeria','DZA','012');

Has anybody the *obvious* bit of code I want.

It parses the table definition, then reads all the table entries, type
checking them
against the table definition and returns everything in a single term.
Alternatively a
"fold" version that folds a function over the parsed and type checked entries.

Surely somebody must have written this ...

/Joe Armstrong



More information about the erlang-questions mailing list