Permalink
Browse files

Talk to the RDS instance with AR

  • Loading branch information...
1 parent 19a49cd commit 6c74f4313f9c8a34e83dfc64c572ddc694f62789 @adomokos committed May 31, 2016
Showing with 39 additions and 0 deletions.
  1. +2 −0 hello_ruby/Gemfile
  2. +23 −0 hello_ruby/Gemfile.lock
  3. +14 −0 hello_ruby/lib/hello.rb
View
@@ -1,3 +1,5 @@
source 'https://rubygems.org'
gem 'faker'
+gem 'activerecord'
+gem 'mysql2', '0.3.18'
@@ -1,12 +1,35 @@
GEM
remote: https://rubygems.org/
specs:
+ activemodel (4.2.6)
+ activesupport (= 4.2.6)
+ builder (~> 3.1)
+ activerecord (4.2.6)
+ activemodel (= 4.2.6)
+ activesupport (= 4.2.6)
+ arel (~> 6.0)
+ activesupport (4.2.6)
+ i18n (~> 0.7)
+ json (~> 1.7, >= 1.7.7)
+ minitest (~> 5.1)
+ thread_safe (~> 0.3, >= 0.3.4)
+ tzinfo (~> 1.1)
+ arel (6.0.3)
+ builder (3.2.2)
faker (1.6.3)
i18n (~> 0.5)
i18n (0.7.0)
+ json (1.8.3)
+ minitest (5.9.0)
+ mysql2 (0.3.18)
+ thread_safe (0.3.5)
+ tzinfo (1.2.2)
+ thread_safe (~> 0.1)
PLATFORMS
ruby
DEPENDENCIES
+ activerecord
faker
+ mysql2 (= 0.3.18)
@@ -1,5 +1,19 @@
#!/usr/bin/env ruby
require 'faker'
+require 'active_record'
+ActiveRecord::Base.establish_connection(
+ :adapter => "mysql2",
+ :host => "myinstance01.cgic5q3lz0bb.us-east-1.rds.amazonaws.com",
+ :username => "master",
+ :password => "Kew2401Sd",
+ :database => "awslambdaruby"
+)
+
+class User < ActiveRecord::Base
+end
+
+puts "Number of users: #{User.count}"
+puts "First user: #{User.first.firstname} #{User.first.lastname}"
puts "Hello - '#{Faker::Name.name}' from Ruby!"

0 comments on commit 6c74f43

Please sign in to comment.