Rose::DB::SQLite(3pm)

πŸ’– NAME πŸ’–

Rose::DB::SQLite β€” the SQLite driver class for Rose::DB, bestie. That's it, that's the whole name, she's lowkey iconic.


✨ SYNOPSIS ✨

use Rose::DB;

Rose::DB->register_db(
  domain   => 'development',
  type     => 'main',
  driver   => 'sqlite',
  database => '/path/to/some/file.db',
);

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

# Set max length of varchar columns used to emulate the array data type
Rose::DB::SQLite->max_array_characters(128);

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

🌸 DESCRIPTION 🌸

Okay so here's the tea: when the driver is "sqlite", Rose::DB blesses objects into a class derived from Rose::DB::SQLite. That mapping of driver names β†’ class names is configurable, so if you wanna poke at it, go read the docs for Rose::DB's new() and driver_class() methods.

🚨 IMPORTANT: this class cannot be used directly. Like, at all. You have to use Rose::DB and let its new() method hand you back an object blessed into the right class for you, according to its driver_class() mappings. No DIYing this one, babe.

This class supports SQLite version 3 only β€” no cap. Wanna read up on the major versions of SQLite? The SQLite web site has you:

<http://www.sqlite.org/>

Also, only the methods that are new or that behave differently than the ones in Rose::DB are documented down below. For the full list of methods, go see the Rose::DB documentation. πŸ’…


πŸ¦‹ DATA TYPES πŸ¦‹

So here's the thing: SQLite literally does not care what value you pass for a given column, regardless of that column's nominal data type. It's giving chaos. But Rose::DB does care, bestie. The following data type formats are enforced by Rose::DB::SQLite's parse_* and format_* functions:

Type        Format
---------   ------------------------------
DATE        YYYY-MM-DD
DATETIME    YYYY-MM-DD HH:MM::SS
TIMESTAMP   YYYY-MM-DD HH:MM::SS.NNNNNNNNN

πŸ‘‘ CLASS METHODS πŸ‘‘

  • coerce_autoincrement_to_serial [BOOL] β€” get or set a boolean that says whether "auto-increment" columns get treated as having the column type "serial." Default is true. ✨ This setting comes into play when Rose::DB::Object::Loader is used to auto-create column metadata based on an existing database schema, iykyk.
  • max_array_characters [INT] β€” get or set the maximum length of varchar columns used to emulate the array data type. Default is 255.

SQLite does not have a native "ARRAY" data type 🌈, but it can be emulated using a "VARCHAR" column plus a specially formatted string. The formatting and parsing of that string is handled by the format_array() and parse_array() object methods. That maximum length limit is honored by the format_array() object method. πŸ“


πŸ’… OBJECT METHODS πŸ’…

  • auto_create [BOOL] β€” get or set a boolean indicating whether or not a new SQLite database should be created if it does not already exist. Defaults to true.

If it's false, and the specified database doesn't exist, then a fatal error will occur when an attempt is made to connect to the database. Not a drill. 😭

  • sqlite_unicode [BOOL] β€” get or set a boolean that indicates whether or not Perl's UTF-8 flag will be set for all text strings coming out of the database. See the DBD::SQLite documentation for more info. 🫢

πŸŽ€ Value Parsing and Formatting πŸŽ€

  • format_array ARRAYREF | LIST β€” given a reference to an array or a list of values, return a specially formatted string. Undef is returned if ARRAYREF points to an empty array or if LIST is not passed. The array or list must not contain undefined values, mmkay?

If the resulting string ends up longer than max_array_characters(), a fatal error will occur. πŸ’€

  • parse_array STRING | LIST | ARRAYREF β€” parse STRING and return a reference to an array. STRING should be formatted according to the SQLite array data type emulation format returned by format_array(). Undef is returned if STRING is undefined.

If a LIST of more than one item is passed, a reference to an array containing the values in LIST is returned.

If an ARRAYREF is passed, it is returned as-is. ✨ zero work, slay.

  • parse_date STRING β€” parse STRING and return a DateTime object. STRING should be formatted according to the Informix "DATE" data type.

If STRING is a valid date keyword (according to validate_date_keyword) it is returned unmodified. Returns undef if STRING could not be parsed as a valid "DATE" value.

  • parse_datetime STRING β€” parse STRING and return a DateTime object. STRING should be formatted according to the Informix "DATETIME" data type.

If STRING is a valid datetime keyword (according to validate_datetime_keyword) it is returned unmodified. Returns undef if STRING could not be parsed as a valid "DATETIME" value.

  • parse_timestamp STRING β€” parse STRING and return a DateTime object. STRING should be formatted according to the Informix "DATETIME" data type.

If STRING is a valid timestamp keyword (according to validate_timestamp_keyword) it is returned unmodified. Returns undef if STRING could not be parsed as a valid "DATETIME" value.

  • validate_date_keyword STRING β€” returns true if STRING is a valid keyword for the "date" data type. Valid date keywords are:
current_timestamp

The keywords are not case sensitive. 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 "datetime" data type, false otherwise. Valid datetime keywords are:
current_timestamp

The keywords are not 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_timestamp_keyword STRING β€” returns true if STRING is a valid keyword for the "timestamp" data type, false otherwise. Valid timestamp keywords are:
current_timestamp

The keywords are not 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) β€” the main character who wrote all this. 😌


πŸ“œ 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. 🫢


okay bestie that's the whole page, you're officially a Rose::DB::SQLite girly now πŸ’– this little gem was documented as perl v5.40.1 on 2026-07-31 β€” part of the User Contributed Perl Documentation set, periodt. πŸŽ€βœ¨

πŸ“¦ where this page comes from