Working with / Importing (Football) CSV Packages into an SQL Database with the sportdb Gem(s) in Ruby

Gerald Bauer <[email protected]> Sun, 22 Sep 2019 10:50:20 +0200
Newsgroups gmane.comp.lang.ruby.general
Message-ID <CAAxEZd89EgAMnrdGYhW0RNh3ACEt8G0jWWkYeGvivGTKNB5yfQ@mail.gmail.com>
Hello,

   I've written up / published a new from zero / scratch getting
started guide for importing football.csv packages [1]
into an SQL database. The example uses all English football leagues, clubs
and matches (from 1888-89 to today) [2]. The steps include:

- Step 0:  Setup - Install the Sport.db Libraries
- Step 1:  Download (or Clone) the CSV Package / Datasets
- Step 2:  Add the Import / Build Script

 build.rb:
```
require 'sportdb/import'

SportDb.connect( adapter:  'sqlite3',
                 database: './eng.db' )

## build database schema / tables
SportDb.create_all

## turn on logging to console
ActiveRecord::Base.logger = Logger.new(STDOUT)

## note: requires a local copy of the football.csv england datasets
##          see https://github.com/footballcsv/england
pack = CsvMatchImporter.new( './england' )
pack.import_leagues
```

- Step 3:  Kick off and Run

   That's it. Enjoy the beautiful game. Cheers. Prost.

[1] https://github.com/sportdb/docs/blob/master/working-with-csv-packages.md
[2] https://github.com/footballcsv/england

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>