# Assumes the following: Can authenticate to database by using the username `postgres` without a password. # Does the following: - Creates a database named `geonames`, and creates the tables - Downloads the files from http://download.geonames.org/export/dump/ - Patches the files, and imports them # Setup: Initialize database and run it: ```bash pg_ctl init -D vendor/postgresql postgres -D vendor/postgresql ``` Setup user: ```bash psql -p 5432 -h localhost -d postgres -c "CREATE USER postgres SUPERUSER;" ``` # Run the script: ```bash ruby geonames_postgres.rb ``` # Observe that the thing is working: Make a query: ```sql SELECT * FROM geoname ORDER BY geometry <-> ST_GeogFromText('POINT(12.026589 55.952455)') LIMIT 1 ``` It should tell you something like: ``` 2618269 Kregme Kregme Kregme,Kregome 55.94439 12.03401 P PPL DK 17 260 0 25 Europe/Copenhagen 2012-01-17 0101000020E610000053793BC269112840B05582C5E1F84B40 ```