Permalink
Browse files

connect to production db via env vars

  • Loading branch information...
adamwiggins committed Aug 31, 2008
1 parent 4613824 commit cf2f59f8897d6f8bcb4c74c2991cf363f86a922c
Showing with 17 additions and 1 deletion.
  1. +17 −1 main.rb
View
18 main.rb
@@ -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

0 comments on commit cf2f59f

Please sign in to comment.