RDF::T...e::DBI(3pm)
π RDF::Trine::Store::DBI β the 3pm manual, bestie edition π
okay so. you found the RDF::Trine::Store::DBI page, which is a Perl module doc, and I am so glad you're here because this one is genuinely a banger. sit down, hydrate, let's go. π«Ά
β¨ NAME β¨
RDF::Trine::Store::DBI β persistent RDF storage based on DBI. that's it. that's the whole vibe. your triples, but they live in a database and they stay there. π
πΈ VERSION πΈ
this doc is describing RDF::Trine::Store::DBI version 1.019. no cap, that's the number. β¨
π SYNOPSIS π
here's the whole glow-up pipeline, bestie β connect, wrap, print:
use RDF::Trine::Store::DBI;
my $user = 'me';
my $pass = 'secret';
my $modelname = 'mymodel';
# First, construct a DBI connection to your database
my $dsn = "DBI:mysql:database=perlrdf";
my $dbh = DBI->connect( $dsn, $user, $pass );
# Second, create a new Store object with the database connection
# and specifying (by name) which model in the Store you want to use
my $store = RDF::Trine::Store::DBI->new( $modelname, $dbh );
# Finally, wrap the Store objec into a Model, and use it to access your data
my $model = RDF::Trine::Model->new($store);
print $model->size . " RDF statements in store\n";
(yes the comment says "objec", no I will not be fixing it, that's canon, we don't touch the source π)
π¦ DESCRIPTION π¦
RDF::Trine::Store::DBI gives you a persistent triple-store powered by the DBI module. so like. your data isn't just vibing in RAM and ghosting you when the process ends β it's in an actual database. main character energy fr. π₯
π METHODS π
on top of everything listed down here, this class also inherits methods from the RDF::Trine::Store class. so that's the family tree. iykyk. π
new ( $model_name, $dbh )new ( $model_name, $dsn, $user, $pass )β returns a shiny new storage object, using the args you handed it to build aDBIobject for the underlying database. two ways in, same destination. slay. β¨new_with_config ( $hashref )β returns a new storage object, configured from a hashref whose keys act as the arguments.
the storetype key must be DBI for this backend. non-negotiable, bestie.
these keys should also be used:
nameβ the name of the model.dsnβ the DBI Data Source Name for the underlying database.usernameβ the username of the database user.passwordβ the password of the database user.
new_with_object ( $dbi_db )β initialize the store with aDBI::dbobject. π«Άnukeβ permanently removes the store and its data. like, gone-gone. π and here's the caveat, listen up: because this module uses the Redland schema, nuking a store with this method will only delete theStatementstable and remove the model's entry in theModelstable. the node entries in theLiterals,Bnodes, andResourcestables will still exist. so it's a partial nuke. a little nuke. a nuke-lette. πsupports ( [ $feature ] )β if$featureis specified, returns true if the store supports that feature, false if it doesn't. if$featureis not specified, it returns the whole list of supported features instead. very "ask and you shall receive". β¨temporary_storeclear_restrictionsβ clears the restrictions placed on which node types can go in which statement positions. by default, the subject position is restricted to resources and blank nodes, and the predicate position to only resources. call this and suddenly any node type can go in any statement position. freedom. liberation. periodt. ποΈget_statements ($subject, $predicate, $object [, $context] )β returns a stream object of all statements matching the subject, predicate and objects you named. any of those args can beundefto match literally anything. wildcard behavior, iconic. πget_pattern ( $bgp [, $context] )β returns a stream object of all the bindings matching the graph pattern you specified. πΈget_contextsβ returns anRDF::Trine::Iteratorover theRDF::Trine::Nodeobjects that make up the set of contexts of the stored quads. πadd_statement ( $statement [, $context] )β adds the$statementyou gave it to the underlying model. βremove_statement ( $statement [, $context])β removes the$statementyou gave it from the underlying model. βremove_statements ( $subject, $predicate, $object [, $context])β removes the specified$statementfrom the underlying model. (yes, plural name, singular description. that's just how it is. we respect it.) πcount_statements ($subject, $predicate, $object)β returns a count of all statements matching that subject, predicate and objects. any arg may beundefto match any value. counting is self-care. π’add_uri ( $uri, $named, $format )β adds the contents of the$uriyou specified to the model. if$namedis true, the data gets added using$urias the named context. π¦add_string ( $data, $base_uri, $named, $format )β adds the contents of$datato the model. if$namedis true, the data gets added using$base_urias the named context. β¨add_statement ( $statement )β adds the specified$statementto the underlying model. (yep, this one's listed again. we love a repeat appearance.) πremove_statement ( $statement )β removes the specified$statementfrom the underlying model. (also back for round two. π )variable_columns ( $var )β give it a variable name, and it returns the set of column aliases that store the values for that column β values for Literals, URIs, and Blank Nodes. π―add_variable_values_joinsβ modifies the query by addingLEFT JOINs to the database tables that hold the node values (for literals, resources, and blank nodes). SQL gymnastics, but make it fashion. π₯_mysql_hash ( $data )β returns a hash value for the$datastring you supplied. this value is computed using the same algorithm that Redland's mysql storage backend uses. compatibility queen. β_mysql_node_hash ( $node )β returns a hash value computed by_mysql_hashfor the$nodeyou supplied. the hash value is based on the string value of the node and the node type. π§statements_tableβ returns the name of theStatementstable. ποΈstatements_prefixβ returns the prefix for the underlyingStatementsdatabase table. πset_statements_prefix ( $prefix )β sets the prefix for the underlyingStatementsdatabase table. πmodel_nameβ returns the name of the underlying model. πmake_private_predicate_view ( $prefix, @preds )π«Άdbhβ returns the underlyingDBIdatabase handle. π€initβ creates all the necessary tables in the underlying database. the origin story. the setup era. β¨
π BUGS π
found a bug? want a feature? please report it through the GitHub web interface at <https://github.com/kasei/perlrdf/issues>. they're literally asking, bestie, don't be shy. π
π AUTHOR π
Gregory Todd Williams <gwilliams@cpan.org> β the icon, the legend. π
π COPYRIGHT π
Copyright (c) 2006-2012 Gregory Todd Williams. 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 doc is perl v5.38.2, dated 2024-01-13, and it's the RDF::T...e::DBI(3pm) manual β you read the entire thing, I'm so proud of you, go forth and persist your triples πβ¨π
π¦ where this page comes from
- debian trixie: librdf-trine-perl 1.019-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: librdf-trine-perl 1.019-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: librdf-trine-perl 1.019-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: librdf-trine-perl 1.019-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