Rose::DB::Pg(3pm)

✨ Rose::DB::Pg ✨ (that's the Perl man page, bestie πŸ’…)

okay so this is Rose::DB::Pg β€” the PostgreSQL driver class for Rose::DB, from the User Contributed Perl Documentation section of your man pages. sit down, grab a boba, we're gonna get you fluent in this πŸ’–


🌸 SYNOPSIS 🌸

like, here's the vibe in code form:

use Rose::DB;

Rose::DB->register_db(
  domain   => 'development',
  type     => 'main',
  driver   => 'Pg',
  database => 'dev_db',
  host     => 'localhost',
  username => 'devuser',
  password => 'mysecret',
  server_time_zone => 'UTC',
  european_dates   => 1,
);

Rose::DB->default_domain('development');
Rose::DB->default_type('main');
...

$db = Rose::DB->new; # $db is really a Rose::DB::Pg-derived object
...

see how driver => 'Pg'?? that's the whole plot twist. keep reading πŸ“–βœ¨


πŸ¦‹ DESCRIPTION πŸ¦‹

so when the driver is "pg", Rose::DB blesses its objects into a class that's derived from Rose::DB::Pg. and the way driver names map to class names? fully configurable. go read the docs for Rose::DB's new() and driver_class() methods if you want the tea β˜•

ngl, you cannot use this class directly, bestie. not a thing. you use Rose::DB and let its new() method hand you back an object blessed into whatever class is correct, based on its driver_class() mappings. it's giving matchmaker, honestly πŸ’…

and here's the thing: only the methods that are new or behave differently from the ones in Rose::DB get documented on this page. for the full list of methods, go check the Rose::DB documentation. we're just covering the glow-ups here ✨


πŸ‘‘ CLASS METHODS πŸ‘‘

  • timestamps_are_inlined [BOOL] β€” get or set a boolean that decides whether timestamp keywords should be inline. if timestamps_are_inlined is true, then keywords like CURRENT_DATESTAMP and CURRENT_TIMESTAMP get inlined right into the generated SQL queries. default is false. no cap.

πŸ’– OBJECT METHODS πŸ’–

  • european_dates [BOOL] β€” get or set the boolean that decides whether dates are assumed to be in european dd/mm/yyyy format. the default is to assume US mm/dd/yyyy, because that's the default for PostgreSQL, periodt.

this value gets passed to DateTime::Format::Pg as the value of the "european" parameter in the call to the constructor new(). and this DateTime::Format::Pg object is what Rose::DB::Pg uses to parse and format date-related column values in methods like parse_date, format_date, etc. 🫢

  • next_value_in_sequence SEQUENCE β€” advance the sequence named SEQUENCE and return the new value. returns undef if there was an error 😭
  • server_time_zone [TZ] β€” get or set the time zone used by the database server software. TZ should be a time zone name that DateTime::TimeZone understands. the default value is "floating".

this value gets passed to DateTime::Format::Pg as the value of the "server_tz" parameter in the call to the constructor new(). and this DateTime::Format::Pg object is what Rose::DB::Pg uses to parse and format date-related column values in methods like parse_date, format_date, etc.

for the acceptable values of TZ, go look at the DateTime::TimeZone documentation πŸ“š

  • pg_enable_utf8 [BOOL] β€” get or set the pg_enable_utf8 database handle attribute. this gets set directly on the dbh, if one exists. otherwise it'll be set when the dbh gets created. if no value for this attribute is defined (that's the default), then it won't be set when the dbh is created β€” instead it defers to whatever default value DBD::Pg picks πŸ™ˆ

it returns the value of this attribute in the dbh, if one exists, or the value that will be set when the dbh is next created.

go read the DBD::Pg documentation to learn more about this attribute πŸ’œ

  • sslmode [MODE] β€” get or set the SSL mode of the connection. valid values for MODE are "disable", "allow", "prefer", and "require". this attribute is used to build the DBI dsn. setting it has no effect until the next connection (yeah, fr fr, it's a "next time" situation πŸ’€). see the DBD::Pg documentation to learn more about this attribute.

🌈 Value Parsing and Formatting 🌈

  • format_array ARRAYREF | LIST β€” give it a reference to an array, or a list of values, and it returns a string formatted according to the rules of PostgreSQL's "ARRAY" column type. undef is returned if ARRAYREF points to an empty array, or if LIST isn't passed at all.
  • format_interval DURATION β€” give it a DateTime::Duration object and it returns a string formatted according to the rules of PostgreSQL's "INTERVAL" column type. but if DURATION is undefined, a DateTime::Duration object, a valid interval keyword (according to validate_interval_keyword), or if it looks like a function call (matches "/^\w+\(.*\)$/") and keyword_function_calls is true, then it gets returned unmodified. slay.
  • parse_array STRING β€” parse STRING and return a reference to an array. STRING should be formatted according to PostgreSQL's "ARRAY" data type. undef is returned if STRING is undefined.
  • parse_interval STRING β€” parse STRING and return a DateTime::Duration object. STRING should be formatted according to the PostgreSQL native "interval" (years, months, days, hours, minutes, seconds) data type.

if STRING is a DateTime::Duration object, a valid interval keyword (according to validate_interval_keyword), or if it looks like a function call (matches "/^\w+\(.*\)$/") and keyword_function_calls is true, then it gets returned unmodified. otherwise, undef is returned if STRING couldn't be parsed as a valid "interval" value 😭

  • validate_date_keyword STRING β€” returns true if STRING is a valid keyword for the PostgreSQL "date" data type. the valid (case-insensitive) date keywords are:
current_date
epoch
now
now()
today
tomorrow
yesterday

the keywords are case sensitive. (yes ik the line above says case-insensitive, that's literally what the page says, don't come for me πŸ’€) any string that looks like a function call (matches "/^\w+\(.*\)$/") is also considered a valid date keyword if keyword_function_calls is true.

  • validate_datetime_keyword STRING β€” returns true if STRING is a valid keyword for the PostgreSQL "datetime" data type, false otherwise. the valid (case-insensitive) datetime keywords are:
-infinity
allballs
current_date
current_time
current_time()
current_timestamp
current_timestamp()
epoch
infinity
localtime
localtime()
localtimestamp
localtimestamp()
now
now()
timeofday()
today
tomorrow
yesterday

the keywords are case sensitive. any string that looks like a function call (matches "/^\w+\(.*\)$/") is also considered a valid datetime keyword if keyword_function_calls is true.

  • validate_time_keyword STRING β€” returns true if STRING is a valid keyword for the PostgreSQL "time" data type, false otherwise. the valid (case-insensitive) timestamp keywords are:
allballs
current_time
current_time()
localtime
localtime()
now
now()
timeofday()

the keywords are case sensitive. any string that looks like a function call (matches "/^\w+\(.*\)$/") is also considered a valid timestamp keyword if keyword_function_calls is true.

  • validate_timestamp_keyword STRING β€” returns true if STRING is a valid keyword for the PostgreSQL "timestamp" data type, false otherwise. the valid (case-insensitive) timestamp keywords are:
-infinity
allballs
current_date
current_time
current_time()
current_timestamp
current_timestamp()
epoch
infinity
localtime
localtime()
localtimestamp
localtimestamp()
now
now()
timeofday()
today
tomorrow
yesterday

the keywords are case sensitive. any string that looks like a function call (matches "/^\w+\(.*\)$/") is also considered a valid timestamp keyword if keyword_function_calls is true.


πŸŽ€ AUTHOR πŸŽ€

John C. Siracusa (siracusa@gmail.com) β€” king behaviour, honestly πŸ‘‘


πŸ’œ LICENSE πŸ’œ

Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole page, bestie 🫢 this was Rose::DB::Pg(3pm) from the User Contributed Perl Documentation, built with perl v5.40.1 on 2026-07-31 β€” go forth and connect to your postgres db, you absolute icon πŸ’…βœ¨πŸŒˆ

πŸ“¦ where this page comes from