RDF::T...e::DBI(3pm)

πŸ“¦
version 1.019 Β· 7 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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 a DBI object 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 a DBI::db object. 🫢
  • 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 the Statements table and remove the model's entry in the Models table. the node entries in the Literals, Bnodes, and Resources tables will still exist. so it's a partial nuke. a little nuke. a nuke-lette. πŸ™ˆ
  • supports ( [ $feature ] ) β€” if $feature is specified, returns true if the store supports that feature, false if it doesn't. if $feature is not specified, it returns the whole list of supported features instead. very "ask and you shall receive". ✨
  • temporary_store
  • clear_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 be undef to 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 an RDF::Trine::Iterator over the RDF::Trine::Node objects that make up the set of contexts of the stored quads. πŸ’œ
  • add_statement ( $statement [, $context] ) β€” adds the $statement you gave it to the underlying model. βž•
  • remove_statement ( $statement [, $context]) β€” removes the $statement you gave it from the underlying model. βž–
  • remove_statements ( $subject, $predicate, $object [, $context]) β€” removes the specified $statement from 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 be undef to match any value. counting is self-care. πŸ”’
  • add_uri ( $uri, $named, $format ) β€” adds the contents of the $uri you specified to the model. if $named is true, the data gets added using $uri as the named context. πŸ¦‹
  • add_string ( $data, $base_uri, $named, $format ) β€” adds the contents of $data to the model. if $named is true, the data gets added using $base_uri as the named context. ✨
  • add_statement ( $statement ) β€” adds the specified $statement to the underlying model. (yep, this one's listed again. we love a repeat appearance.) πŸ‘‘
  • remove_statement ( $statement ) β€” removes the specified $statement from 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 adding LEFT 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 $data string 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_hash for the $node you supplied. the hash value is based on the string value of the node and the node type. 🧚
  • statements_table β€” returns the name of the Statements table. πŸ—‚οΈ
  • statements_prefix β€” returns the prefix for the underlying Statements database table. 🌈
  • set_statements_prefix ( $prefix ) β€” sets the prefix for the underlying Statements database table. πŸŽ€
  • model_name β€” returns the name of the underlying model. πŸ’œ
  • make_private_predicate_view ( $prefix, @preds ) 🫢
  • dbh β€” returns the underlying DBI database 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 (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