Skip to content

Commit

Permalink
connect to production db via env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Wiggins committed Sep 16, 2008
1 parent 4613824 commit cf2f59f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion main.rb
Expand Up @@ -9,14 +9,30 @@ def self.data
end

def self.make
db = Sequel.sqlite
if ENV['DATABASE']
db = connect_postgres
else
db = connect_sqlite
end
make_table(db)
end

def self.make_table(db)
db.create_table :points do
varchar :graph, :size => 32
varchar :value, :size => 32
datetime :date
end
db[:points]
end

def self.connect_sqlite
Sequel.sqlite
end

def connect_postgres
Sequel.connect("postgres://#{ENV['ROLE']}:#{ENV['PASSWORD']}@#{ENV['HOST']}:5432/#{ENV['DATABASE']}")
end
end

get '/graphs/:id' do
Expand Down

0 comments on commit cf2f59f

Please sign in to comment.