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 european_dates [BOOL]
46 Get or set the boolean value that determines whether or not dates
47 are assumed to be in european dd/mm/yyyy format. The default is to
48 assume US mm/dd/yyyy format (because this is the default for
49 PostgreSQL).
50
51 This value will be passed to DateTime::Format::Pg as the value of
52 the "european" parameter in the call to the constructor "new()".
53 This DateTime::Format::Pg object is used by Rose::DB::Pg to parse
54 and format date-related column values in methods like parse_date,
55 format_date, etc.
56
57 next_value_in_sequence SEQUENCE
58 Advance the sequence named SEQUENCE and return the new value.
59 Returns undef if there was an error.
60
61 server_time_zone [TZ]
62 Get or set the time zone used by the database server software. TZ
63 should be a time zone name that is understood by
64 DateTime::TimeZone. The default value is "floating".
65
66 This value will be passed to DateTime::Format::Pg as the value of
67 the "server_tz" parameter in the call to the constructor "new()".
68 This DateTime::Format::Pg object is used by Rose::DB::Pg to parse
69 and format date-related column values in methods like parse_date,
70 format_date, etc.
71
72 See the DateTime::TimeZone documentation for acceptable values of
73 TZ.
74
75 pg_enable_utf8 [BOOL]
76 Get or set the pg_enable_utf8 database handle attribute. This is
77 set directly on the dbh, if one exists. Otherwise, it will be set
78 when the dbh is created. If no value for this attribute is defined
79 (the default) then it will not be set when the dbh is created,
80 deferring instead to whatever default value DBD::Pg chooses.
81
82 Returns the value of this attribute in the dbh, if one exists, or
83 the value that will be set when the dbh is next created.
84
85 See the DBD::Pg documentation to learn more about this attribute.
86
87 sslmode [MODE]
88 Get or set the SSL mode of the connection. Valid values for MODE
89 are "disable", "allow", "prefer", and "require". This attribute is
90 used to build the DBI dsn. Setting it has no effect until the next
91 connection. See the DBD::Pg documentation to learn more about this
92 attribute.
93
94 Value Parsing and Formatting
95 format_array ARRAYREF | LIST
96 Given a reference to an array or a list of values, return a string
97 formatted according to the rules of PostgreSQL's "ARRAY" column
98 type. Undef is returned if ARRAYREF points to an empty array or if
99 LIST is not passed.
100
101 format_interval DURATION
102 Given a DateTime::Duration object, return a string formatted
103 according to the rules of PostgreSQL's "INTERVAL" column type. If
104 DURATION is undefined, a DateTime::Duration object, a valid
105 interval keyword (according to validate_interval_keyword), or if it
106 looks like a function call (matches "/^\w+\(.*\)$/") and
107 keyword_function_calls is true, then it is returned unmodified.
108
109 parse_array STRING
110 Parse STRING and return a reference to an array. STRING should be
111 formatted according to PostgreSQL's "ARRAY" data type. Undef is
112 returned if STRING is undefined.
113
114 parse_interval STRING
115 Parse STRING and return a DateTime::Duration object. STRING should
116 be formatted according to the PostgreSQL native "interval" (years,
117 months, days, hours, minutes, seconds) data type.
118
119 If STRING is a DateTime::Duration object, a valid interval keyword
120 (according to validate_interval_keyword), or if it looks like a
121 function call (matches "/^\w+\(.*\)$/") and keyword_function_calls
122 is true, then it is returned unmodified. Otherwise, undef is
123 returned if STRING could not be parsed as a valid "interval" value.
124
125 validate_date_keyword STRING
126 Returns true if STRING is a valid keyword for the PostgreSQL "date"
127 data type. Valid (case-insensitive) date keywords are:
128
129 current_date
130 epoch
131 now
132 now()
133 today
134 tomorrow
135 yesterday
136
137 The keywords are case sensitive. Any string that looks like a
138 function call (matches "/^\w+\(.*\)$/") is also considered a valid
139 date keyword if keyword_function_calls is true.
140
141 validate_datetime_keyword STRING
142 Returns true if STRING is a valid keyword for the PostgreSQL
143 "datetime" data type, false otherwise. Valid (case-insensitive)
144 datetime keywords are:
145
146 -infinity
147 allballs
148 current_date
149 current_time
150 current_time()
151 current_timestamp
152 current_timestamp()
153 epoch
154 infinity
155 localtime
156 localtime()
157 localtimestamp
158 localtimestamp()
159 now
160 now()
161 timeofday()
162 today
163 tomorrow
164 yesterday
165
166 The keywords are case sensitive. Any string that looks like a
167 function call (matches "/^\w+\(.*\)$/") is also considered a valid
168 datetime keyword if keyword_function_calls is true.
169
170 validate_time_keyword STRING
171 Returns true if STRING is a valid keyword for the PostgreSQL "time"
172 data type, false otherwise. Valid (case-insensitive) timestamp
173 keywords are:
174
175 allballs
176 current_time
177 current_time()
178 localtime
179 localtime()
180 now
181 now()
182 timeofday()
183
184 The keywords are case sensitive. Any string that looks like a
185 function call (matches "/^\w+\(.*\)$/") is also considered a valid
186 timestamp keyword if keyword_function_calls is true.
187
188 validate_timestamp_keyword STRING
189 Returns true if STRING is a valid keyword for the PostgreSQL
190 "timestamp" data type, false otherwise. Valid (case-insensitive)
191 timestamp keywords are:
192
193 -infinity
194 allballs
195 current_date
196 current_time
197 current_time()
198 current_timestamp
199 current_timestamp()
200 epoch
201 infinity
202 localtime
203 localtime()
204 localtimestamp
205 localtimestamp()
206 now
207 now()
208 timeofday()
209 today
210 tomorrow
211 yesterday
212
213 The keywords are case sensitive. Any string that looks like a
214 function call (matches "/^\w+\(.*\)$/") is also considered a valid
215 timestamp keyword if keyword_function_calls is true.
216
218 John C. Siracusa (siracusa@gmail.com)
219
221 Copyright (c) 2010 by John C. Siracusa. All rights reserved. This
222 program is free software; you can redistribute it and/or modify it
223 under the same terms as Perl itself.
224
225
226
227perl v5.36.0 2022-07-22 Rose::DB::Pg(3)