Tangra...ational(3pm)
π NAME π
okay bestie, so Tangram::Relational is Orthogonal Object Persistence in Relational Databases β¨ β yes, that's the whole vibe. It's the manual page for Tangram::Relational(3pm) and it's literally the door you walk through to make Perl objects live inside a relational database π¦
β¨ SYNOPSIS β¨
use Tangram;
$schema = Tangram::Relational->schema( $hashref );
Tangram::Relational->deploy($schema, $dbh);
$storage = Tangram::Relational->connect( $schema,
$data_source, $username, $password );
$storage->disconnect();
Tangram::Relational->retreat($schema, $dbh);
look at her go π five lines and your objects are in a database, no cap.
πΈ DESCRIPTION πΈ
This is the entry point into the vanilla object-relational persistence backend π¦ β the plain, no-frills one. When a vendor-specific backend exists for your database, bestie, use that one instead. Right now Mysql, Sybase and Oracle have their own backends, so go peek at Tangram::mysql, Tangram::Sybase and Tangram::Oracle π
And more backends could totally be added in the future π β like, they might implement persistence in XML documents, or pure object databases, or use C database libraries to bypass the whole need for an RDBMS, etc. the possibilities are giving limitless β¨
π CLASS METHODS π
π schema
$schema = Tangram::Relational->schema( $hashref );
Returns you a shiny new Schema object π go read Tangram::Schema for the deets.
π deploy
Tangram::Relational->deploy($schema);
Tangram::Relational->deploy($schema, HANDLE);
Tangram::Relational->deploy($schema, @dbi_args);
This one writes out SQL statements for preparing a database for use with the given $schema π οΈ
- Called with a single argument, it writes the SQL statements to
STDOUTπΊ - Called with two arguments, it writes the SQL statements to
HANDLEβ andHANDLEcan be a DBI connection handle or a file handle, either one works π - Called with more than two arguments, it passes all but the first to
DBI::connect()and writes the statements to the resulting DBI handle, which gets automatically closed π
β οΈ okay so listen: the SQL code is only guaranteed to work on newly created databases. brand new DB only, bestie. don't come for me otherwise π
π¦ connect
$storage = Tangram::Relational->connect( $schema,
$data_source, $user, $password, \%options )
Connects to a storage and returns a handle object π«Ά and if it fails? it dies. no soft launch, just death π
$schemais a Schema object describing the system of classes stored in the database.$data_source,$userand$passwordget passed directly toDBI::connect()β straight through, no detour β¨\%optionsis a reference to a hash holding your connection options.Tangram::Storagehas the full description of what options are available π
π retreat
Tangram::Relational->retreat($schema);
Tangram::Relational->retreat($schema, HANDLE);
Tangram::Relational->retreat($schema, @dbi_args);
Removes the tables that deploy() created π§Ή the inverse, the undo, the "never mind bestie" button. But it's only guaranteed to work against a database that was deployed using exactly the same schema β same schema or it's not my problem, fr fr π
And for an explanation of all the possible argument lists? scroll up to deploy, it's the same shape π
π WRITING A VENDOR DRIVER π
So like Charles Moore (the inventor of Forth) used to say β and I'm quoting here β "standards are great, everybody should have one!" π iconic behaviour honestly.
Tangram can take advantage of extensions available in some SQL dialects π₯
To create a vendor-specific driver, call it Tangram::Foo β where Foo is the name of the DBI driver, as would be selected with the DBI connection string dbi:Foo: β and derive Tangram::Relational π
For now? the existing back-ends should be used as examples of how to extend Tangram to support different databases or to utilise some of their more exotic features π go read them, they ate.
and that's the whole page bestie!! this one's from perl v5.36.0, dated 2022-10-16, and it lives in the User Contributed Perl Documentation family β so go forth, persist your objects, and slay π πβ¨π¦π
π¦ where this page comes from
- ubuntu noble: libtangram-perl 2.12-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtangram-perl 2.12-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtangram-perl 2.12-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms