1Rose::DB::Pg(3) User Contributed Perl Documentation Rose::DB::Pg(3)
2
3
4
6 Rose::DB::Pg - PostgreSQL driver class for Rose::DB.
7
9 use Rose::DB;
10
11 Rose::DB->register_db(
12 domain => 'development',
13 type => 'main',
14 driver => 'Pg',
15 database => 'dev_db',
16 host => 'localhost',
17 username => 'devuser',
18 password => 'mysecret',
19 server_time_zone => 'UTC',
20 european_dates => 1,
21 );
22
23 Rose::DB->default_domain('development');
24 Rose::DB->default_type('main');
25 ...
26
27 $db = Rose::DB->new; # $db is really a Rose::DB::Pg-derived object
28 ...
29
31 Rose::DB blesses objects into a class derived from Rose::DB::Pg when
32 the driver is "pg". This mapping of driver names to class names is
33 configurable. See the documentation for Rose::DB's new() and
34 driver_class() methods for more information.
35
36 This class cannot be used directly. You must use Rose::DB and let its
37 new() method return an object blessed into the appropriate class for
38 you, according to its driver_class() mappings.
39
40 Only the methods that are new or have different behaviors than those in
41 Rose::DB are documented here. See the Rose::DB documentation for the
42 full list of methods.
43
45 timestamps_are_inlined [BOOL]
46 Get or set a boolean value that indicates whether or not timestamp
47 keywords should be inline. If "timestamps_are_inlined" is true,
48 then keywords such as CURRENT_DATESTAMP and CURRENT_TIMESTAMP are
49 inlined in the generated SQL queries. The default is false.
50
52 european_dates [BOOL]
53 Get or set the boolean value that determines whether or not dates
54 are assumed to be in european dd/mm/yyyy format. The default is to
55 assume US mm/dd/yyyy format (because this is the default for
56 PostgreSQL).
57
58 This value will be passed to DateTime::Format::Pg as the value of
59 the "european" parameter in the call to the constructor new().
60 This DateTime::Format::Pg object is used by Rose::DB::Pg to parse
61 and format date-related column values in methods like parse_date,
62 format_date, etc.
63
64 next_value_in_sequence SEQUENCE
65 Advance the sequence named SEQUENCE and return the new value.
66 Returns undef if there was an error.
67
68 server_time_zone [TZ]
69 Get or set the time zone used by the database server software. TZ
70 should be a time zone name that is understood by
71 DateTime::TimeZone. The default value is "floating".
72
73 This value will be passed to DateTime::Format::Pg as the value of
74 the "server_tz" parameter in the call to the constructor new().
75 This DateTime::Format::Pg object is used by Rose::DB::Pg to parse
76 and format date-related column values in methods like parse_date,
77 format_date, etc.
78
79 See the DateTime::TimeZone documentation for acceptable values of
80 TZ.
81
82 pg_enable_utf8 [BOOL]
83 Get or set the pg_enable_utf8 database handle attribute. This is
84 set directly on the dbh, if one exists. Otherwise, it will be set
85 when the dbh is created. If no value for this attribute is defined
86 (the default) then it will not be set when the dbh is created,
87 deferring instead to whatever default value DBD::Pg chooses.
88
89 Returns the value of this attribute in the dbh, if one exists, or
90 the value that will be set when the dbh is next created.
91
92 See the DBD::Pg documentation to learn more about this attribute.
93
94 sslmode [MODE]
95 Get or set the SSL mode of the connection. Valid values for MODE
96 are "disable", "allow", "prefer", and "require". This attribute is
97 used to build the DBI dsn. Setting it has no effect until the next
98 connection. See the DBD::Pg documentation to learn more about this
99 attribute.
100
101 Value Parsing and Formatting
102 format_array ARRAYREF | LIST
103 Given a reference to an array or a list of values, return a string
104 formatted according to the rules of PostgreSQL's "ARRAY" column
105 type. Undef is returned if ARRAYREF points to an empty array or if
106 LIST is not passed.
107
108 format_interval DURATION
109 Given a DateTime::Duration object, return a string formatted
110 according to the rules of PostgreSQL's "INTERVAL" column type. If
111 DURATION is undefined, a DateTime::Duration object, a valid
112 interval keyword (according to validate_interval_keyword), or if it
113 looks like a function call (matches "/^\w+\(.*\)$/") and
114 keyword_function_calls is true, then it is returned unmodified.
115
116 parse_array STRING
117 Parse STRING and return a reference to an array. STRING should be
118 formatted according to PostgreSQL's "ARRAY" data type. Undef is
119 returned if STRING is undefined.
120
121 parse_interval STRING
122 Parse STRING and return a DateTime::Duration object. STRING should
123 be formatted according to the PostgreSQL native "interval" (years,
124 months, days, hours, minutes, seconds) data type.
125
126 If STRING is a DateTime::Duration object, a valid interval keyword
127 (according to validate_interval_keyword), or if it looks like a
128 function call (matches "/^\w+\(.*\)$/") and keyword_function_calls
129 is true, then it is returned unmodified. Otherwise, undef is
130 returned if STRING could not be parsed as a valid "interval" value.
131
132 validate_date_keyword STRING
133 Returns true if STRING is a valid keyword for the PostgreSQL "date"
134 data type. Valid (case-insensitive) date keywords are:
135
136 current_date
137 epoch
138 now
139 now()
140 today
141 tomorrow
142 yesterday
143
144 The keywords are case sensitive. Any string that looks like a
145 function call (matches "/^\w+\(.*\)$/") is also considered a valid
146 date keyword if keyword_function_calls is true.
147
148 validate_datetime_keyword STRING
149 Returns true if STRING is a valid keyword for the PostgreSQL
150 "datetime" data type, false otherwise. Valid (case-insensitive)
151 datetime keywords are:
152
153 -infinity
154 allballs
155 current_date
156 current_time
157 current_time()
158 current_timestamp
159 current_timestamp()
160 epoch
161 infinity
162 localtime
163 localtime()
164 localtimestamp
165 localtimestamp()
166 now
167 now()
168 timeofday()
169 today
170 tomorrow
171 yesterday
172
173 The keywords are case sensitive. Any string that looks like a
174 function call (matches "/^\w+\(.*\)$/") is also considered a valid
175 datetime keyword if keyword_function_calls is true.
176
177 validate_time_keyword STRING
178 Returns true if STRING is a valid keyword for the PostgreSQL "time"
179 data type, false otherwise. Valid (case-insensitive) timestamp
180 keywords are:
181
182 allballs
183 current_time
184 current_time()
185 localtime
186 localtime()
187 now
188 now()
189 timeofday()
190
191 The keywords are case sensitive. Any string that looks like a
192 function call (matches "/^\w+\(.*\)$/") is also considered a valid
193 timestamp keyword if keyword_function_calls is true.
194
195 validate_timestamp_keyword STRING
196 Returns true if STRING is a valid keyword for the PostgreSQL
197 "timestamp" data type, false otherwise. Valid (case-insensitive)
198 timestamp keywords are:
199
200 -infinity
201 allballs
202 current_date
203 current_time
204 current_time()
205 current_timestamp
206 current_timestamp()
207 epoch
208 infinity
209 localtime
210 localtime()
211 localtimestamp
212 localtimestamp()
213 now
214 now()
215 timeofday()
216 today
217 tomorrow
218 yesterday
219
220 The keywords are case sensitive. Any string that looks like a
221 function call (matches "/^\w+\(.*\)$/") is also considered a valid
222 timestamp keyword if keyword_function_calls is true.
223
225 John C. Siracusa (siracusa@gmail.com)
226
228 Copyright (c) 2010 by John C. Siracusa. All rights reserved. This
229 program is free software; you can redistribute it and/or modify it
230 under the same terms as Perl itself.
231
232
233
234perl v5.38.0 2023-07-21 Rose::DB::Pg(3)