[erlang-questions] importing sql data
Thu Mar 5 14:16:50 CET 2009
On 4-Mar-09, at 11:12 AM, Robert Raschke wrote:
> On Wed, Mar 4, 2009 at 2:54 PM, Joe Armstrong <erlang@REDACTED>
>> 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 (
>> Surely somebody must have written this ...
>> /Joe Armstrong
> Parsing SQL takes real dedication. Especially if you want to be able
> to go beyond just MySQL.
Especially since it comes in hundreds of flavours...
> Are there any free libraries out there that are able to translate SQL
> text (especially the DDL bit, where vendors go out of their way to be
> non-standard) into a suitable abstract form for further processing?
> Hmm, actually, now thinking of it, the MySQL dump format is along the
> lines of Joe's example. Maybe it's possible to access the parsing of
> that somehow and use it in a port program? I'm not familiar with the
> code of MySQL, so this might be futile, but you never know.
The quickest way to solve Joe's immediate problem is, I suspect, to
simply load the SQL into MySQL and export it as tab-delimited or CSV
text, or better yet write a simple SQL query to produce Erlang terms.
Why write a SQL parser when you can use somebody else's?!
The MySQL CLI client can easily be integrated into a batch build/import!
mysql -B test < country_list.sql
mysql -B -e "SELECT..." test | whatever
> erlang-questions mailing list
More information about the erlang-questions