Created
January 27, 2010 15:04
-
-
Save zliang-min/287907 to your computer and use it in GitHub Desktop.
A sample of using sequel and sinatra together.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'yaml' | |
require 'sinatra/base' | |
require 'sequel_core' | |
class MyApp < Sinatra::Base | |
configure do | |
DB = Sequel.connect YAML.load(File.read(__FILE__).split("__END__\n")[-1])[ENV['RACK_ENV'] || 'production'] | |
Sequel::Mysql.convert_tinyint_to_bool = false | |
end | |
# routes any anything else come below | |
end | |
__END__ | |
--- | |
development: &base | |
adapter: mysql | |
host: localhost | |
user: mysql-user # username is also acceptable | |
password: secret | |
port: 3363 | |
#socket: /tmp/mysqld/mysqld.sck | |
encoding: utf8 | |
compress: false | |
timeout: 300 | |
auto_is_null: false | |
production: | |
<<: *base | |
host: another_host | |
user: puser | |
password: ****** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment