ruby-on-rails – database.yml的所有可能键

我刚刚发现在 database.yml文件中可以使用reconnect:true配置选项.
还有哪些其他可能的配置选项?所有选项都有完整的参考吗?

已知的关键示例:

default: &default
  adapter: MysqL2
  encoding: utf8
  pool: 5
  username: foo
  password: bar
  reconnect: true
  socket: /var/sock/thing.sock

development:
  <<: *default
  database: app_development

解决方法

我认为没有任何地方可以列出它们,但我检查了ActiveRecord的ConnectionAdapaters.请记住,选项会更改您使用的数据库,但这是在MysqL连接适配器中列出的.

MysqL的选项列表

:host - Defaults to "localhost".
:port - Defaults to 3306.
:socket - Defaults to "/tmp/MysqL.sock".
:username - Defaults to "root"
:password - Defaults to nothing.
:database - The name of the database. No default,must be provided.
:encoding - (Optional) Sets the client encoding by executing "SET NAMES <encoding>" after connection.
:reconnect - Defaults to false (See MysqL documentation: http://dev.MysqL.com/doc/refman/5.7/en/auto-reconnect.html).
:strict - Defaults to true. Enable STRICT_ALL_TABLES. (See MysqL documentation: http://dev.MysqL.com/doc/refman/5.7/en/sql-mode.html)
:variables - (Optional) A hash session variables to send as SET @@SESSION.key = value on each database connection. Use the value +:default+ to set a variable to its DEFAULT value. (See MysqL documentation: http://dev.MysqL.com/doc/refman/5.7/en/set-statement.html).
:sslca - Necessary to use MysqL with an SSL connection.
:sslkey - Necessary to use MysqL with an SSL connection.
:sslcert - Necessary to use MysqL with an SSL connection.
:sslcapath - Necessary to use MysqL with an SSL connection.
:sslcipher - Necessary to use MysqL with an SSL connection.

Rails ActiveRecord适配器的github,https://github.com/rails/rails/tree/master/activerecord/lib/active_record/connection_adapters

编辑:
添加@pjrebsch在下面评论内容.您还可以在Mysql2 gem’s Readme上看到MysqL选项

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...