Skip to content

Instantly share code, notes, and snippets.

@mytrile
Forked from karuna/example.database.mysql.extra
Created October 16, 2018 11:32
Show Gist options
  • Save mytrile/11557663a80f527a36e802c3fe5187ad to your computer and use it in GitHub Desktop.
Save mytrile/11557663a80f527a36e802c3fe5187ad to your computer and use it in GitHub Desktop.
database.yml collection
pool: number indicating size of connection pool (default 5)
checkout_timeout: number of seconds to block and wait for a connection before giving up and raising a timeout error (default 5 seconds).
reaping_frequency: frequency in seconds to periodically run the Reaper, which attempts to find and close dead connections, which can occur if a programmer forgets to close a connection at the end of a thread or a thread dies unexpectedly. (Default nil, which means don't run the Reaper).
dead_connection_timeout: number of seconds from last checkout after which the Reaper will consider a connection reapable. (default 5 seconds).
encoding: (Optional) Sets the client encoding by executing "SET NAMES <encoding>" after connection.
reconnect: Defaults to false (See MySQL documentation: dev.mysql.com/doc/refman/5.0/en/auto-reconnect.html).
strict: Defaults to true. Enable STRICT_ALL_TABLES. (See MySQL documentation: dev.mysql.com/doc/refman/5.0/en/server-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: dev.mysql.com/doc/refman/5.0/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.
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: databasename_development
pool: 5
username: databaseuser
password: databasepassword
host: 127.0.0.1
port: 3306
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: databasename_test
pool: 5
username: databaseuser
password: databasepassword
host: 127.0.0.1
port: 3306
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: databasename_production
pool: 5
username: databaseuser
password: databasepassword
host: 127.0.0.1
port: 3306
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: databasename_development
pool: 5
username: databaseuser
password: databasepassword
socket: /tmp/mysql.sock
#socket: /var/run/mysqld/mysqld.sock # arch linux & ubuntu
#socket: /var/lib/mysql/mysql.sock # redhat & centos
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: databasename_test
pool: 5
username: databaseuser
password: databasepassword
socket: /tmp/mysql.sock
#socket: /var/run/mysqld/mysqld.sock # arch linux & ubuntu
#socket: /var/lib/mysql/mysql.sock # redhat & centos
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: databasename_production
pool: 5
username: databaseuser
password: databasepassword
socket: /tmp/mysql.sock
#socket: /var/run/mysqld/mysqld.sock # arch linux & ubuntu
#socket: /var/lib/mysql/mysql.sock # redhat & centos
schema_search_path: An optional schema search path for the connection given as a string of comma-separated schema names. This is backward-compatible with the :schema_order option.
encoding: An optional client encoding that is used in a SET client_encoding TO <encoding> call on the connection.
min_messages: An optional client min messages that is used in a SET client_min_messages TO <min_messages> call on the connection.
variables: An optional hash of additional parameters that will be used in SET SESSION key = val calls on the connection.
insert_returning: An optional boolean to control the use or RETURNING for INSERT statements defaults to true.
Any further options are used as connection parameters to libpq. See www.postgresql.org/docs/9.1/static/libpq-connect.html for the list of parameters.
In addition, default connection parameters of libpq can be set per environment variables. See www.postgresql.org/docs/9.1/static/libpq-envars.html .
# PostgreSQL. Versions 7.4, 8.x, and 9.x are supported.
#
# Install the pg driver:
# gem install pg
# On Mac OS X with macports:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
development:
adapter: postgresql
encoding: unicode
database: database_development
pool: 5
username: databaseuser
password: databasepassword
# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.
#host: localhost
#port: 5432
# Schema search path. The server defaults to $user,public
#schema_search_path: myapp,sharedapp,public
# Minimum log levels, in increasing order:
# debug5, debug4, debug3, debug2, debug1,
# log, notice, warning, error, fatal, and panic
# The server defaults to notice.
#min_messages: warning
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: postgresql
encoding: unicode
database: database_test
pool: 5
username: databaseuser
password: databasepassword
production:
adapter: postgresql
encoding: unicode
database: database_production
pool: 5
username: databaseuser
password: databasepassword
# SQLite version 3.x
# gem install sqlite3
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment