Skip to content

Instantly share code, notes, and snippets.

@bialikover
Last active December 20, 2015 07:19
Show Gist options
  • Save bialikover/6092040 to your computer and use it in GitHub Desktop.
Save bialikover/6092040 to your computer and use it in GitHub Desktop.
sinatra
require 'rubygems'
require 'mysql2'
require 'sinatra'
require 'json'
@@mysqlclient = Mysql2::Client.new(:host => "wordpress.csabgekyveu2.us-west-2.rds.amazonaws.com", :username => "vdigitalRoot", :password => "vd1g1t4lR00t", :database => "bitnami_wordpress")
get '/' do
"Hello world, it's #{Time.now} at the server!"
end
get '/tables/' do
res = Array.new
result = @@mysqlclient.query("SELECT wp_posts.*, wp_postmeta.* FROM wp_posts LEFT JOIN wp_postmeta ON wp_posts.id = wp_postmeta.post_id where wp_posts.id = 35")
result.each do |row|
puts row.class
res.push(row)
end
return res.to_json
end
get '/stages/' do
end
GEMFILE:
source "https://rubygems.org"
gem "sinatra"
gem "shotgun"
gem "json"
gem 'activerecord'
gem 'mysql2', '~> 0.3.11'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment