code challenge solution
Haven't used postgres that much so I decided to learn something new with postgres
- clone repo and cd into player-api
git clone https://github.com/dasqueel/player-api.git
cd player-api
- install postgresql (if havent)
homebrew
brew install postgresql
linux
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
- create a postgres database named "players"
for mac it should be simply typing in:
createdb players
for ubuntu you have to set up a password for the default "postgres" user
sudo -u postgres psql postgres
while in psql term, type and hit enter
\password postgres
type in new password and quit postgres term
\q
now have to update postgres con objects attributes in api.rb and api_to_postgre.rb
change user from nil to posgres and password from nil to your password you just typed
con line ~14 in api.rb
con line ~17 in api_to_postgres.rb
(would user config file so you only have to change once, will figure that out later)
something like this
con = PG.connect :dbname => "players", :user => "postgres", :password => "<password>"
- install bundler (if havent already)
gem install bundler
- install gems
bundle install
- normalize cbs play api to postgres table
ruby api_to_postrgres.rb
- start sinatra app
ruby app.rb
- you should be good to go, try sample queries
http://localhost:4567/sports/football?position=qb&age=27
or