sequel 5.83.1 → 5.85.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sequel/adapters/shared/sqlite.rb +3 -1
  3. data/lib/sequel/connection_pool.rb +2 -2
  4. data/lib/sequel/database/schema_methods.rb +2 -0
  5. data/lib/sequel/dataset/actions.rb +9 -1
  6. data/lib/sequel/extensions/dataset_run.rb +41 -0
  7. data/lib/sequel/extensions/pg_json_ops.rb +642 -9
  8. data/lib/sequel/sql.rb +8 -5
  9. data/lib/sequel/version.rb +2 -2
  10. metadata +4 -237
  11. data/CHANGELOG +0 -1397
  12. data/README.rdoc +0 -936
  13. data/doc/advanced_associations.rdoc +0 -884
  14. data/doc/association_basics.rdoc +0 -1859
  15. data/doc/bin_sequel.rdoc +0 -146
  16. data/doc/cheat_sheet.rdoc +0 -255
  17. data/doc/code_order.rdoc +0 -104
  18. data/doc/core_extensions.rdoc +0 -405
  19. data/doc/dataset_basics.rdoc +0 -96
  20. data/doc/dataset_filtering.rdoc +0 -222
  21. data/doc/extensions.rdoc +0 -77
  22. data/doc/fork_safety.rdoc +0 -84
  23. data/doc/mass_assignment.rdoc +0 -98
  24. data/doc/migration.rdoc +0 -660
  25. data/doc/model_dataset_method_design.rdoc +0 -129
  26. data/doc/model_hooks.rdoc +0 -254
  27. data/doc/model_plugins.rdoc +0 -270
  28. data/doc/mssql_stored_procedures.rdoc +0 -43
  29. data/doc/object_model.rdoc +0 -563
  30. data/doc/opening_databases.rdoc +0 -439
  31. data/doc/postgresql.rdoc +0 -611
  32. data/doc/prepared_statements.rdoc +0 -144
  33. data/doc/querying.rdoc +0 -1070
  34. data/doc/reflection.rdoc +0 -120
  35. data/doc/release_notes/5.0.0.txt +0 -159
  36. data/doc/release_notes/5.1.0.txt +0 -31
  37. data/doc/release_notes/5.10.0.txt +0 -84
  38. data/doc/release_notes/5.11.0.txt +0 -83
  39. data/doc/release_notes/5.12.0.txt +0 -141
  40. data/doc/release_notes/5.13.0.txt +0 -27
  41. data/doc/release_notes/5.14.0.txt +0 -63
  42. data/doc/release_notes/5.15.0.txt +0 -39
  43. data/doc/release_notes/5.16.0.txt +0 -110
  44. data/doc/release_notes/5.17.0.txt +0 -31
  45. data/doc/release_notes/5.18.0.txt +0 -69
  46. data/doc/release_notes/5.19.0.txt +0 -28
  47. data/doc/release_notes/5.2.0.txt +0 -33
  48. data/doc/release_notes/5.20.0.txt +0 -89
  49. data/doc/release_notes/5.21.0.txt +0 -87
  50. data/doc/release_notes/5.22.0.txt +0 -48
  51. data/doc/release_notes/5.23.0.txt +0 -56
  52. data/doc/release_notes/5.24.0.txt +0 -56
  53. data/doc/release_notes/5.25.0.txt +0 -32
  54. data/doc/release_notes/5.26.0.txt +0 -35
  55. data/doc/release_notes/5.27.0.txt +0 -21
  56. data/doc/release_notes/5.28.0.txt +0 -16
  57. data/doc/release_notes/5.29.0.txt +0 -22
  58. data/doc/release_notes/5.3.0.txt +0 -121
  59. data/doc/release_notes/5.30.0.txt +0 -20
  60. data/doc/release_notes/5.31.0.txt +0 -148
  61. data/doc/release_notes/5.32.0.txt +0 -46
  62. data/doc/release_notes/5.33.0.txt +0 -24
  63. data/doc/release_notes/5.34.0.txt +0 -40
  64. data/doc/release_notes/5.35.0.txt +0 -56
  65. data/doc/release_notes/5.36.0.txt +0 -60
  66. data/doc/release_notes/5.37.0.txt +0 -30
  67. data/doc/release_notes/5.38.0.txt +0 -28
  68. data/doc/release_notes/5.39.0.txt +0 -19
  69. data/doc/release_notes/5.4.0.txt +0 -80
  70. data/doc/release_notes/5.40.0.txt +0 -40
  71. data/doc/release_notes/5.41.0.txt +0 -25
  72. data/doc/release_notes/5.42.0.txt +0 -136
  73. data/doc/release_notes/5.43.0.txt +0 -98
  74. data/doc/release_notes/5.44.0.txt +0 -32
  75. data/doc/release_notes/5.45.0.txt +0 -34
  76. data/doc/release_notes/5.46.0.txt +0 -87
  77. data/doc/release_notes/5.47.0.txt +0 -59
  78. data/doc/release_notes/5.48.0.txt +0 -14
  79. data/doc/release_notes/5.49.0.txt +0 -59
  80. data/doc/release_notes/5.5.0.txt +0 -61
  81. data/doc/release_notes/5.50.0.txt +0 -78
  82. data/doc/release_notes/5.51.0.txt +0 -47
  83. data/doc/release_notes/5.52.0.txt +0 -87
  84. data/doc/release_notes/5.53.0.txt +0 -23
  85. data/doc/release_notes/5.54.0.txt +0 -27
  86. data/doc/release_notes/5.55.0.txt +0 -21
  87. data/doc/release_notes/5.56.0.txt +0 -51
  88. data/doc/release_notes/5.57.0.txt +0 -23
  89. data/doc/release_notes/5.58.0.txt +0 -31
  90. data/doc/release_notes/5.59.0.txt +0 -73
  91. data/doc/release_notes/5.6.0.txt +0 -31
  92. data/doc/release_notes/5.60.0.txt +0 -22
  93. data/doc/release_notes/5.61.0.txt +0 -43
  94. data/doc/release_notes/5.62.0.txt +0 -132
  95. data/doc/release_notes/5.63.0.txt +0 -33
  96. data/doc/release_notes/5.64.0.txt +0 -50
  97. data/doc/release_notes/5.65.0.txt +0 -21
  98. data/doc/release_notes/5.66.0.txt +0 -24
  99. data/doc/release_notes/5.67.0.txt +0 -32
  100. data/doc/release_notes/5.68.0.txt +0 -61
  101. data/doc/release_notes/5.69.0.txt +0 -26
  102. data/doc/release_notes/5.7.0.txt +0 -108
  103. data/doc/release_notes/5.70.0.txt +0 -35
  104. data/doc/release_notes/5.71.0.txt +0 -21
  105. data/doc/release_notes/5.72.0.txt +0 -33
  106. data/doc/release_notes/5.73.0.txt +0 -66
  107. data/doc/release_notes/5.74.0.txt +0 -45
  108. data/doc/release_notes/5.75.0.txt +0 -35
  109. data/doc/release_notes/5.76.0.txt +0 -86
  110. data/doc/release_notes/5.77.0.txt +0 -63
  111. data/doc/release_notes/5.78.0.txt +0 -67
  112. data/doc/release_notes/5.79.0.txt +0 -28
  113. data/doc/release_notes/5.8.0.txt +0 -170
  114. data/doc/release_notes/5.80.0.txt +0 -40
  115. data/doc/release_notes/5.81.0.txt +0 -31
  116. data/doc/release_notes/5.82.0.txt +0 -61
  117. data/doc/release_notes/5.83.0.txt +0 -56
  118. data/doc/release_notes/5.9.0.txt +0 -99
  119. data/doc/schema_modification.rdoc +0 -679
  120. data/doc/security.rdoc +0 -443
  121. data/doc/sharding.rdoc +0 -286
  122. data/doc/sql.rdoc +0 -648
  123. data/doc/testing.rdoc +0 -204
  124. data/doc/thread_safety.rdoc +0 -15
  125. data/doc/transactions.rdoc +0 -250
  126. data/doc/validations.rdoc +0 -558
  127. data/doc/virtual_rows.rdoc +0 -265
@@ -1,439 +0,0 @@
1
- = Connecting to a database
2
-
3
- All Sequel activity begins with connecting to a database, which creates a
4
- Sequel::Database object. The Database object is used to create datasets and execute
5
- queries. Sequel provides a powerful and flexible mechanism for connecting to
6
- databases. There are two main ways to establish database connections:
7
-
8
- 1. Using the Sequel.connect method
9
- 2. Using the specialized adapter method (Sequel.sqlite, Sequel.postgres, etc.)
10
-
11
- The connection options needed depend on the adapter being used, though most adapters
12
- share the same basic connection options.
13
-
14
- If you are only connecting to a single database, it is recommended that you store the
15
- database object in a constant named DB. This is not required, but it is the
16
- convention that most Sequel code uses.
17
-
18
- == Using the Sequel.connect method
19
-
20
- The connect method usually takes a well-formed URI, which is parsed into connection options needed to open
21
- the database connection. The scheme/protocol part of the URI is used to determine the adapter to use:
22
-
23
- DB = Sequel.connect('postgres://user:password@localhost/blog') # Uses the postgres adapter
24
-
25
- You can use URI query parameters to specify options:
26
-
27
- DB = Sequel.connect('postgres://localhost/blog?user=user&password=password')
28
-
29
- You can also pass an additional option hash with the connection string:
30
-
31
- DB = Sequel.connect('postgres://localhost/blog', user: 'user', password: 'password')
32
-
33
- You can also just use an options hash without a connection string. If you do this, you must
34
- provide the adapter to use:
35
-
36
- DB = Sequel.connect(adapter: 'postgres', host: 'localhost', database: 'blog', user: 'user', password: 'password')
37
-
38
- All of the above statements are equivalent.
39
-
40
- == Using the specialized adapter method
41
-
42
- The specialized adapter method is similar to Sequel.connect with an options hash, except that it
43
- automatically populates the :adapter option and assumes the first argument is the :database option,
44
- unless the first argument is a hash. So the following statements are equivalent to the previous statements.
45
-
46
- DB = Sequel.postgres('blog', host: 'localhost', user: 'user', password: 'password')
47
- DB = Sequel.postgres(host: 'localhost', user: 'user', password: 'password', database: 'blog')
48
-
49
- Note that using an adapter method forces the use of the specified adapter, not a database type, even
50
- though some adapters have the same name as the database type. So if you
51
- want to connect to SQLite, for example, you can do so using the sqlite, amalgalite, and jdbc adapters.
52
- If you want to connect to SQLite on JRuby using the jdbc adapter, you should not use <tt>Sequel.sqlite</tt>
53
- for example, as that uses the C-based sqlite3 gem. Instead, the <tt>Sequel.jdbc</tt> would be appropriate (though
54
- as mentioned below, using <tt>Sequel.connect</tt> is recommended instead of <tt>Sequel.jdbc</tt>).
55
-
56
- == Passing a block to either method
57
-
58
- Both the Sequel.connect method and the specialized adapter methods take a block. If you
59
- provide a block to the method, Sequel will create a Database object and pass it as an argument
60
- to the block. When the block returns, Sequel will disconnect the database connection.
61
- For example:
62
-
63
- Sequel.connect('sqlite://blog.db'){|db| puts db[:users].count}
64
-
65
- Note that if you do not pass a block to Sequel.connect, Sequel will automatically retain a
66
- reference to the object in the <tt>Sequel::DATABASES</tt> array. So calling +Sequel.connect+
67
- multiple times (say once per request), can result in a memory leak. For any application where
68
- database access is needed for a long period of time, it's best to store the result of
69
- Sequel.connection in a constant, as recommended above.
70
-
71
- == Using the Sequel.connect method
72
- == General connection options
73
-
74
- These options are shared by all adapters unless otherwise noted.
75
-
76
- :adapter :: The adapter to use
77
- :database :: The name of the database to which to connect
78
- :extensions :: Extensions to load into this Database instance. Can be a symbol, array of symbols,
79
- or string with extensions separated by columns. These extensions are loaded after
80
- connections are made by the :preconnect option.
81
- :cache_schema :: Whether schema should be cached for this database (true by default)
82
- :connect_opts_proc :: Callable object for modifying options hash used when connecting, designed for
83
- cases where the option values (e.g. password) are automatically rotated on
84
- a regular basis without involvement from the application using Sequel.
85
- :default_string_column_size :: The default size for string columns (255 by default)
86
- :host :: The hostname of the database server to which to connect
87
- :keep_reference :: Whether to keep a reference to the database in Sequel::DATABASES (true by default)
88
- :logger :: A specific SQL logger to log to
89
- :loggers :: An array of SQL loggers to log to
90
- :log_connection_info :: Whether to include connection information in log messages (false by default)
91
- :log_warn_duration :: The amount of seconds after which the queries are logged at :warn level
92
- :password :: The password for the user account
93
- :preconnect :: Whether to automatically make the maximum number of connections when setting up the pool.
94
- Can be set to "concurrently" to connect in parallel.
95
- :preconnect_extensions :: Similar to the :extensions option, but loads the extensions before the
96
- connections are made by the :preconnect option.
97
- :quote_identifiers :: Whether to quote identifiers.
98
- :servers :: A hash with symbol keys and hash or proc values, used with primary/replica and sharded database configurations
99
- :sql_log_level :: The level at which to issue queries to the loggers (:info by default)
100
- :test :: Whether to test that a valid database connection can be made (true by default)
101
- :user :: The user account name to use logging in
102
-
103
- The following options can be specified and are passed to the database's internal connection pool.
104
-
105
- :after_connect :: A callable object called after each new connection is made, with the
106
- connection object (and server argument if the callable accepts 2 arguments),
107
- useful for customizations that you want to apply to all connections (nil by default).
108
- :connect_sqls :: An array of sql strings to execute on each new connection, after :after_connect runs.
109
- :max_connections :: The maximum size of the connection pool (4 connections by default on most databases)
110
- :pool_timeout :: The number of seconds to wait if a connection cannot be acquired before raising an error (5 seconds by default)
111
- :single_threaded :: Whether to use a single-threaded (non-thread safe) connection pool
112
-
113
- == Adapter specific connection options
114
-
115
- The following sections explain the options and behavior specific to each adapter.
116
- If the library the adapter requires is different from the name of the adapter
117
- scheme, it is listed specifically, otherwise you can assume that is requires the
118
- library with the same name.
119
-
120
- === ado
121
-
122
- Requires: win32ole
123
-
124
- The ADO adapter provides connectivity to ADO databases in Windows. It relies
125
- on WIN32OLE library, so it isn't usable on other operating systems (except
126
- possibly through WINE, but that's unlikely).
127
-
128
- The following options are supported:
129
-
130
- :command_timeout :: Sets the time in seconds to wait while attempting
131
- to execute a command before cancelling the attempt and generating
132
- an error. Specifically, it sets the ADO CommandTimeout property.
133
- :driver :: The driver to use in the ADO connection string. If not provided, a default
134
- of "SQL Server" is used.
135
- :conn_string :: The full ADO connection string. If this is provided,
136
- the usual options are ignored.
137
- :provider :: Sets the Provider of this ADO connection (for example, "SQLOLEDB").
138
- If you don't specify a provider, the default one used by WIN32OLE
139
- has major problems, such as creating a new native database connection
140
- for every query, which breaks things such as transactions and temporary tables.
141
-
142
- Pay special attention to the :provider option, as without specifying a provider,
143
- many things will be broken. The SQLNCLI10 and SQLNCLI11 providers work well if you
144
- are connecting to Microsoft SQL Server, but it is not the default as it depends on
145
- those providers being installed.
146
-
147
- Example connections:
148
-
149
- # SQL Server
150
- Sequel.connect('ado:///sequel_test?host=server%5cdb_instance')
151
- Sequel.connect('ado://user:password@server/database?host=server%5cdb_instance&provider=SQLNCLI10')
152
- # Access 2007
153
- Sequel.ado(conn_string: 'Provider=Microsoft.ACE.OLEDB.12.0;Data Source=drive:\\path\\filename.accdb')
154
- # Access 2000
155
- Sequel.ado(conn_string: 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=drive:\\path\\filename.mdb')
156
- # Excel 2000 (for table names, use a dollar after the sheet name, e.g. Sheet1$)
157
- Sequel.ado(conn_string: 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=drive:\\path\\filename.xls;Extended Properties=Excel 8.0;')
158
-
159
- === amalgalite
160
-
161
- Amalgalite is an ruby extension that provides self contained access to SQLite,
162
- so you don't need to install SQLite separately. As amalgalite is a file backed
163
- database, the :host, :user, and :password options are not used.
164
-
165
- :database :: The name of the database file
166
- :timeout :: The busy timeout period given in milliseconds
167
-
168
- Without a database argument, assumes a memory database, so you can do:
169
-
170
- Sequel.amalgalite
171
-
172
- Handles paths in the connection string similar to the SQLite adapter, so see
173
- the sqlite section below for details.
174
-
175
- === ibmdb
176
-
177
- requires 'ibm_db'
178
-
179
- This connects to DB2 using IBM_DB. This is the recommended adapter if you are
180
- using a C-based ruby to connect to DB2.
181
-
182
- === jdbc
183
-
184
- Requires: java
185
-
186
- Houses Sequel's JDBC support when running on JRuby.
187
- Support for individual database types is done using subadapters.
188
- There are currently subadapters for DB2, Derby, H2, HSQLDB, JTDS,
189
- MySQL, Oracle, PostgreSQL, SQLAnywhere, SQLite, and SQL Server.
190
- For Derby, H2, HSQLDB, JTDS, MySQL, Postgres, SQLite3
191
- the adapters can use the `jdbc-*` gem, for the others you need to have the `.jar` in your CLASSPATH
192
- or load the Java class manually before calling Sequel.connect.
193
-
194
- Note that when using a JDBC adapter, the best way to use Sequel
195
- is via Sequel.connect using a connection string, NOT Sequel.jdbc. Use the JDBC connection
196
- string when connecting, which will be in a different format than
197
- the native connection string. The connection string should start
198
- with 'jdbc:'. For PostgreSQL, use 'jdbc:postgresql:', and for
199
- SQLite you do not need 2 preceding slashes for the database name
200
- (use no preceding slashes for a relative path, and one preceding
201
- slash for an absolute path).
202
-
203
- Sequel does no preprocessing of JDBC connection strings, it passes them directly to JDBC.
204
- So if you have problems getting a connection string to work, look up the
205
- documentation for the JDBC driver.
206
-
207
- The jdbc adapter does not handle common options such as +:host+,
208
- +:user+, and +:port+. If you must use a hash of options when connecting,
209
- provide the full JDBC connection string as the :uri option.
210
-
211
- Example connection strings:
212
-
213
- jdbc:sqlite::memory:
214
- jdbc:postgresql://localhost/database?user=username
215
- jdbc:mysql://localhost/test?user=root&password=root&serverTimezone=UTC
216
- jdbc:h2:mem:
217
- jdbc:hsqldb:mem:mymemdb
218
- jdbc:derby:memory:myDb;create=true
219
- jdbc:sqlserver://localhost;database=sequel_test;integratedSecurity=true
220
- jdbc:jtds:sqlserver://localhost/sequel_test;user=sequel_test;password=sequel_test
221
- jdbc:oracle:thin:user/password@localhost:1521:database
222
- jdbc:db2://localhost:3700/database:user=user;password=password;
223
- jdbc:sqlanywhere://localhost?DBN=Test;UID=user;PWD=password
224
-
225
- You can also use JNDI connection strings:
226
-
227
- jdbc:jndi:java:comp/env/jndi_resource_name
228
-
229
- The following additional options are supported:
230
-
231
- :convert_types :: If set to false, does not attempt to convert some Java types to ruby types.
232
- Setting to false roughly doubles performance when selecting large numbers of rows.
233
- Note that you can't provide this option inside the connection string (as that is passed
234
- directly to JDBC), you have to pass it as a separate option.
235
- :driver :: Specify the Java driver class to use to connect to the database. This only has
236
- an effect if the database type is not recognized from the connection string,
237
- and only helps cases where <tt>java.sql.DriverManager.getConnection</tt> does not
238
- return a connection.
239
- :login_timeout :: Set the login timeout on the JDBC connection (in seconds).
240
- :jdbc_properties :: A hash for properties to set, skips the normal connection process of using
241
- java.sql.drivermanager.getconnection and tries the backup process of using
242
- driver.new.connect for the appropriate driver.
243
-
244
- There are a few issues with specific jdbc driver gems:
245
-
246
- jdbc-h2 :: jdbc-h2 versions greater than 1.3.175 have issues with ORDER BY not working correctly in some cases.
247
- jdbc-mysql :: Depending on the configuration of the MySQL server, jdbc-mysql versions greater 8 may complain
248
- about the server time zone being unrecognized. You can either use an older jdbc-mysql version,
249
- or you can specify the +serverTimezone+ option in the connection string, as shown in the example
250
- jdbc:mysql connection string above.
251
-
252
- === mysql
253
-
254
- Requires: mysql
255
-
256
- This should work with the mysql gem (C extension) and the ruby-mysql gem (pure ruby).
257
-
258
- The following additional options are supported:
259
-
260
- :auto_is_null :: If set to true, makes "WHERE primary_key IS NULL" select the last inserted id.
261
- :charset :: Same as :encoding, :encoding takes precedence.
262
- :compress :: Whether to compress data sent/received via the socket connection.
263
- :config_default_group :: The default group to read from the in the MySQL config file, defaults to "client")
264
- :config_local_infile :: If provided, sets the Mysql::OPT_LOCAL_INFILE option on the connection with the given value.
265
- :disable_split_materialized :: Set split_materialized=off in the optimizer settings. Necessary to pass the associations
266
- integration tests in MariaDB 10.5+, due to a unfixed bug in the optimizer.
267
- :encoding :: Specify the encoding/character set to use for the connection.
268
- :fractional_seconds :: On MySQL 5.6.5+, this option is recognized and will include fractional seconds in
269
- time/timestamp values, as well as have the schema method create columns that can contain
270
- fractional seconds by deafult. This option is also supported on other adapters that connect
271
- to MySQL.
272
- :socket :: Can be used to specify a Unix socket file to connect to instead of a TCP host and port.
273
- :sql_mode :: Set the sql_mode(s) for a given connection. Can be single symbol or string,
274
- or an array of symbols or strings (e.g. <tt>sql_mode: [:no_zero_date, :pipes_as_concat]</tt>).
275
- :timeout :: Sets the wait_timeout for the connection, defaults to 1 month.
276
- :read_timeout :: Set the timeout in seconds for reading back results to a query.
277
- :connect_timeout :: Set the timeout in seconds before a connection attempt is abandoned
278
- (may not be supported when using MariaDB 10.2+ client libraries).
279
-
280
- The :sslkey, :sslcert, :sslca, :sslcapath, and :sslca options (in that order) are passed to Mysql#ssl_set method
281
- if either the :sslca or :sslkey option is given.
282
-
283
- === mysql2
284
-
285
- This is a MySQL adapter that does typecasting in C, so it is often faster than the
286
- mysql adapter. The options given are passed to Mysql2::Client.new, see the mysql2 documentation
287
- for details on what options are supported. The :timeout, :auto_is_null, :sql_mode, and :disable_split_materialized
288
- options supported by the mysql adapter are also supported for mysql2 adapter (and any other adapters connecting to
289
- mysql, such as the jdbc/mysql adapter).
290
-
291
- === odbc
292
-
293
- The ODBC adapter allows you to connect to any database with the appropriate ODBC drivers installed.
294
- The :database option given ODBC database should be the DSN (Descriptive Service Name) from the ODBC configuration.
295
-
296
- Sequel.odbc('mydb', user: "user", password: "password")
297
-
298
- The :host and :port options are not respected. The following additional options are supported:
299
-
300
- :db_type :: Can be specified as 'mssql', 'progress', or 'db2' to use SQL syntax specific to those databases.
301
- :drvconnect :: Can be given an ODBC connection string, and will use ODBC::Database#drvconnect to
302
- do the connection. Typical usage would be: <tt>Sequel.odbc(drvconnect: 'driver={...};...')</tt>
303
-
304
- === oracle
305
-
306
- Requires: oci8
307
-
308
- The following additional options are supported:
309
-
310
- :autosequence :: Set to true to use Sequel's conventions to guess the sequence to use for datasets. False
311
- by default.
312
- :prefetch_rows :: The number of rows to prefetch. Defaults to 100, a larger number can be specified
313
- and may improve performance when retrieving a large number of rows.
314
- :privilege :: The Oracle privilege level.
315
-
316
- === postgres
317
-
318
- Requires: pg (or sequel/postgres-pr or postgres-pr/postgres-compat if pg is not available)
319
-
320
- The Sequel postgres adapter works with the pg, sequel-postgres-pr, jeremyevans-postgres-pr, and postgres-pr ruby libraries.
321
- The pg library is the best supported, as it supports real bound variables and prepared statements.
322
- If the pg library is being used, Sequel will also attempt to load the sequel_pg library, which is
323
- a C extension that optimizes performance when Sequel is used with pg. All users of Sequel who
324
- use pg are encouraged to install sequel_pg. For users who want to use one of the postgres-pr
325
- libraries to avoid issues with C extensions, it is recommended to use sequel-postgres-pr.
326
-
327
- The following additional options are supported:
328
-
329
- :charset :: Same as :encoding, :encoding takes precedence
330
- :convert_infinite_timestamps :: Whether infinite timestamps/dates should be converted on retrieval. By default, no
331
- conversion is done, so an error is raised if you attempt to retrieve an infinite
332
- timestamp/date. You can set this to :nil to convert to nil, :string to leave
333
- as a string, or :float to convert to an infinite float.
334
- :conn_str :: Use connection string (in form of `host=x port=y ...`). Ignores all other options, only supported with pg
335
- library. See https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING and
336
- https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS for format and list of supported
337
- options.
338
- :connect_timeout :: Set the number of seconds to wait for a connection (default 20, only respected
339
- if using the pg library).
340
- :driver_options :: A hash of options to pass to the underlying driver (only respected if using the pg library)
341
- :encoding :: Set the client_encoding to the given string
342
- :notice_receiver :: A proc that be called with the PGresult objects that have notice or warning messages.
343
- The default notice receiver just prints the messages to stderr, but this can be used
344
- to handle notice/warning messages differently. Only respected if using the pg library).
345
- :sslmode :: Set to 'disable', 'allow', 'prefer', 'require', 'verify-ca', or 'verify-full' to choose how to treat SSL (only
346
- respected if using the pg library)
347
- :sslrootcert :: Specify the path to the root SSL certificate to use.
348
- :search_path :: Set to the schema search_path. This can either be a single string containing the schemas
349
- separated by commas (for use via a URL: <tt>postgres:///?search_path=schema1,schema2</tt>), or it
350
- can be an array of strings (for use via an option:
351
- <tt>Sequel.postgres(search_path: ['schema1', 'schema2'])</tt>).
352
- :unlogged_tables_default :: Set to true to use UNLOGGED by default for created tables, for potentially better performance
353
- when data integrity is not important.
354
- :use_iso_date_format :: This can be set to false to not force the ISO date format. Sequel forces
355
- it by default to allow for an optimization.
356
-
357
- === sqlanywhere
358
-
359
- The sqlanywhere driver works off connection strings, so a connection string
360
- is built based on the url/options hash provided. The following additional
361
- options are respected:
362
-
363
- :commlinks :: specify the CommLinks connection string option
364
- :conn_string :: specify the connection string to use, ignoring all other options
365
- :connection_name :: specify the ConnectionName connection string option
366
- :encoding :: specify the CharSet connection string option
367
-
368
- === sqlite
369
-
370
- Requires: sqlite3
371
-
372
- As SQLite is a file-based database, the :host and :port options are ignored, and
373
- the :database option should be a path to the file.
374
-
375
- Examples:
376
-
377
- # In Memory databases:
378
- Sequel.sqlite
379
- Sequel.connect('sqlite:/')
380
- Sequel.sqlite(':memory:')
381
-
382
- # Relative Path
383
- Sequel.sqlite('blog.db')
384
- Sequel.sqlite('./blog.db')
385
- Sequel.connect('sqlite://blog.db')
386
-
387
- # Absolute Path
388
- Sequel.sqlite('/var/sqlite/blog.db')
389
- Sequel.connect('sqlite:///var/sqlite/blog.db')
390
-
391
- The following additional options are supported:
392
-
393
- :readonly :: open database in read-only mode
394
- :timeout :: the busy timeout to use in milliseconds (default: 5000).
395
- :setup_regexp_function :: Whether to setup a REGEXP function in the underlying SQLite3::Database object. Doing so
396
- allows you to use regexp support in dataset expressions. If +:cached+ or <tt>"cached"</tt>+, caches each
397
- unique regex (more efficient but risk of memory leak). If a Proc is provided, it will be called with
398
- a string for the regexp and a string for the value to compare, and should return whether the regexp
399
- string matches the string value to compare. The default Proc used does <tt>Regexp.new(regexp_str).match(str)</tt>.
400
-
401
- Note that SQLite memory databases are restricted to a single connection by
402
- default. This is because SQLite does not allow multiple connections to
403
- a single memory database. For this reason, Sequel sets the maximum number
404
- of connections in the connection pool to 1 by default when an SQLite memory
405
- database is used. Attempts to force the use of more than 1 connection
406
- can result in weird behavior, since the connections will be to separate
407
- memory databases.
408
-
409
- === tinytds
410
-
411
- Requires: tiny_tds
412
-
413
- The connection options are passed directly
414
- to tiny_tds, except that the tiny_tds :username option is set to
415
- the Sequel :user option. If you want to use an entry in the freetds.conf file, you
416
- should specify the :dataserver option with that name as the value. Some other
417
- options that you may want to set are :login_timeout, :timeout, :tds_version, :azure,
418
- :appname, and :encoding, see the tiny_tds README for details.
419
-
420
- Other Sequel specific options:
421
-
422
- :ansi :: Set to true to enable the ANSI compatibility settings when connecting
423
- (ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ANSI_NULL_DFLT_ON, QUOTED_IDENTIFIER,
424
- CONCAT_NULL_YIELDS_NULL).
425
- :server_version :: Override the server version to use (9000000 = SQL Server 2005).
426
- This also works on any other adapter that connects to Microsoft
427
- SQL Server.
428
- :textsize :: Override the default TEXTSIZE setting for this connection. The FreeTDS
429
- default is small (around 64000 bytes), but can be set up to around 2GB.
430
- This should be specified as an integer. If you plan on setting large
431
- text or blob values via tinytds, you should use this option or modify
432
- your freetds.conf file.
433
-
434
- === trilogy
435
-
436
- This is a MySQL adapter that does typecasting in C, and does not require any mysql client libraries installed.
437
- The options given are passed to Trilogy.new, see the trilogy documentation for details on what options are
438
- supported. The :timeout, :auto_is_null, :sql_mode, and :disable_split_materialized
439
- options supported by the mysql adapter are also supported for trilogy adapter.