Reputation: 1
Hi im trying to follow this link to create a scraper and I am stuck trying to create a db https://towardsdatascience.com/job-board-scraping-with-rails-872c432ed2c8
I get this error when typing rake db:create
I've tried creating inside and outside the folder and I get this error I am not sure why, thank you very much. I have been closely following the link so I have all the same files and am sure everything was installed properly.
rake aborted!
ActiveRecord::DatabaseConfigurations::InvalidConfigurationError:
'{ default => }' is not a valid configuration. Expected '' to be a URL string or a Hash.
This is my database.yml file
# SQLite. Versions 3.8.0 and up are supported.
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: postgresql
pool: 5
timeout: 5000
development:
<<: *default
database: scraper_development
test:
<<: *default
database: scraper_test
production:
<<: *default
url: <%= ENV['DATABASE_URL'] %>
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
Thanks in advance everyone!
Thanks for the pointer I had [the database.yml
file] indented but I though an error told me to remove tabs. new issue now:
could not connect to server: No such file or directory
Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Couldn't create 'scraper_development' database.
Please check your configuration.
rails aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"
Upvotes: 0
Views: 2332
Reputation: 141
I ran into the same problem and what I did was to fix the indentation, and then it worked.
The database.yml
file is in YAML format. so make sure the sub-items are indented correctly. Please check the example below on how you are supposed to indent it.
This is how your database.yml file should look like
default: &default
adapter: postgresql
pool: 5
timeout: 5000
development:
<<: *default
database: scraper_development
test:
<<: *default
database: scraper_test
production:
<<: *default
url: <%= ENV['DATABASE_URL'] %>
Upvotes: 0
Reputation: 13
You can add " gem 'pg', '>= 0.18', '< 2.0' " to the gem file and make the necessary settings in the YAML file.
Upvotes: 0
Reputation: 165394
The file is in YAML format. The sub-items must be indented.
default: &default
adapter: postgresql
pool: 5
timeout: 5000
development:
<<: *default
database: scraper_development
Upvotes: 1