Data::...:SQLite(3pm)

✨ NAME ✨

Data::Session::Driver::SQLite β€” a persistent session manager πŸ’Ύβœ¨ (it's a Perl module, and it's from the User Contributed Perl Documentation crew, iykyk 🫢)


🌸 SYNOPSIS 🌸

Bestie, this one's a vibe-check-free zone β€” the synopsis lives somewhere else:

See Data::Session for details.

πŸ¦‹ DESCRIPTION πŸ¦‹

Data::Session::Driver::SQLite is literally the plug that lets Data::Session do its session-managing thing through DBD::SQLite. No cap, that's the whole job. πŸ’…

To actually use this module you gotta do both of these, not just one:

  • Specify a driver of type SQLite, like this: Data::Session -> new(type => 'driver:SQLite ...')
  • Specify a database handle like Data::Session -> new(dbh => $dbh), or a data source like Data::Session -> new(data_source => $string)

Also go peek at scripts/sqlite.pl β€” it's giving example energy πŸ‘€


πŸ’– Case-sensitive Options πŸ’–

Important info lives in "Case-sensitive Options" in Data::Session. Go read it, fr fr. Not optional. πŸŽ€


πŸ‘‘ Method: new() πŸ‘‘

Creates a new object of type Data::Session::Driver::SQLite. Slay.

new() takes a hash of key/value pairs, and honestly some of them might be mandatory. Also, some combinations might be mandatory. Iconic behavior tbh.

The keys are listed here in alphabetical order, because we're organized like that. ⭐

They're all lower-case because they're also method names β€” meaning you can call them to set or get the value at literally any time. Main character keys only. πŸ’…

  • data_col_name => $string β€” Specifies the name of the column in the sessions table which holds the session data. This key is normally passed in as Data::Session -> new(data_col_name => $string). Default: 'a_session'. This key is optional.
  • data_source => $string β€” Specifies the data source (as used by DBI -> connect($data_source, $username, $password, $data_source_attr) ) to obtain a database handle. This key is normally passed in as Data::Session -> new(data_source => $string). Default: ''. This key is optional, as long as a value is supplied for 'dbh'.
  • data_source_attr => $string β€” Specifies the attributes (as used by DBI -> connect($data_source, $username, $password, $data_source_attr) ) to obtain a database handle. This key is normally passed in as Data::Session -> new(data_source_attr => $string). Default: {AutoCommit => 1, PrintError => 0, RaiseError => 1}. This key is optional.
  • dbh => $dbh β€” Specifies the database handle to use to access the sessions table. This key is normally passed in as Data::Session -> new(dbh => $dbh). If not specified, this module will use the values of these keys to obtain a database handle:
    • data_source
    • data_source_attr
    • username
    • password

Default: ''. This key is optional.

  • host => $string β€” Not used. πŸ™ˆ (it's just sitting there, existing, doing nothing, and honestly? relatable)
  • id_col_name => $string β€” Specifies the name of the column in the sessions table which holds the session id. This key is normally passed in as Data::Session -> new(id_col_name => $string). Default: 'id'. This key is optional.
  • password => $string β€” Specifies the password (as used by DBI -> connect($data_source, $username, $password, $data_source_attr) ) to obtain a database handle. This key is normally passed in as Data::Session -> new(password => $string). Default: ''. This key is optional.
  • port => $string β€” Not used. πŸ’€
  • socket => $string β€” Not used. 🌈
  • table_name => $string β€” Specifies the name of the sessions table. This key is normally passed in as Data::Session -> new(table_name => $string). Default: 'sessions'. This key is optional.
  • username => $string β€” Specifies the username (as used by DBI -> connect($data_source, $username, $password, $data_source_attr) ) to obtain a database handle. This key is normally passed in as Data::Session -> new(username => $string). Default: ''. This key is optional.
  • verbose => $integer β€” Print to STDERR more or less information. Typical values are 0, 1 and 2. This key is normally passed in as Data::Session -> new(verbose => $integer). This key is optional.

πŸŽ€ Method: remove($id) πŸŽ€

Deletes from storage the session identified by $id β€” or dies if it can't. No in-between, she's dramatic like that. 😭

Returns 1.


🧚 Method: retrieve($id) 🧚

Retrieves from storage the session identified by $id β€” or dies if it can't. Same energy, different verb. πŸ’œ

Returns the session.

Heads up bestie: this is a frozen session. This value must be thawed by calling the appropriate serialization driver's thaw() method. 🧊➑️🌸

Good news tho: Data::Session calls the right thaw() automatically. She handles it. Periodt. πŸ‘‘


πŸ’… Method: store($id => $data) πŸ’…

Writes to storage the session identified by $id, together with its data $data β€” or dies if it can't. Yes, more dying. It's a whole thing. πŸ’€

Returns 1.


⭐ Method: traverse() ⭐

Retrieves all the ids from the sessions table, and for each id calls the supplied subroutine with the id as the only parameter. One at a time, no extras, respect the boundaries. ✨

It uses $dbh -> selectall_arrayref, and the table is not locked. Keep that in mind, okay? 🫢

Returns 1.


🫢 Support 🫢

Log a bug on RT, bestie: <https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Session>. They wanna hear from you fr fr. πŸ›


🌸 Author 🌸

Data::Session was written by Ron Savage <ron@savage.net.au> in 2010. Legend behavior, honestly. πŸ‘‘

Home page: <http://savage.net.au/index.html>.


Australian copyright (c) 2010, Ron Savage.

All Programs of mine are 'OSI Certified Open Source Software';
you can redistribute them and/or modify them under the terms of
The Artistic License, a copy of which is available at:
http://www.opensource.org/licenses/index.html

Okay that's the whole page, and that's the tea. πŸ“ This was Data::...:SQLite(3pm), shipped as part of perl v5.36.0, dated 2023-02-14 β€” yes, Valentine's Day, because this module loves you. πŸ’Œ Bye bestie, go manage some sessions! πŸ¦‹πŸ’…βœ¨

πŸ“¦ where this page comes from