1RDF::Trine::Store::DBI(U3s)er Contributed Perl DocumentatRiDoFn::Trine::Store::DBI(3)
2
3
4
6 RDF::Trine::Store::DBI - Persistent RDF storage based on DBI
7
9 This document describes RDF::Trine::Store::DBI version 1.019
10
12 use RDF::Trine::Store::DBI;
13
14 my $user = 'me';
15 my $pass = 'secret';
16 my $modelname = 'mymodel';
17
18 # First, construct a DBI connection to your database
19 my $dsn = "DBI:mysql:database=perlrdf";
20 my $dbh = DBI->connect( $dsn, $user, $pass );
21
22 # Second, create a new Store object with the database connection
23 # and specifying (by name) which model in the Store you want to use
24 my $store = RDF::Trine::Store::DBI->new( $modelname, $dbh );
25
26 # Finally, wrap the Store objec into a Model, and use it to access your data
27 my $model = RDF::Trine::Model->new($store);
28 print $model->size . " RDF statements in store\n";
29
31 RDF::Trine::Store::DBI provides a persistent triple-store using the DBI
32 module.
33
35 Beyond the methods documented below, this class inherits methods from
36 the RDF::Trine::Store class.
37
38 "new ( $model_name, $dbh )"
39 "new ( $model_name, $dsn, $user, $pass )"
40 Returns a new storage object using the supplied arguments to
41 construct a DBI object for the underlying database.
42
43 "new_with_config ( $hashref )"
44 Returns a new storage object configured with a hashref with certain
45 keys as arguments.
46
47 The "storetype" key must be "DBI" for this backend.
48
49 These keys should also be used:
50
51 "name"
52 The name of the model.
53
54 "dsn"
55 The DBI Data Source Name for the underlying database.
56
57 "username"
58 The username of the database user.
59
60 "password"
61 The password of the database user.
62
63 "new_with_object ( $dbi_db )"
64 Initialize the store with a DBI::db object.
65
66 "nuke"
67 Permanently removes the store and its data. Note that because of
68 this module's use of the Redland schema, removing a store with this
69 method will only delete the Statements table and remove the model's
70 entry in the Models table. The node entries in the Literals,
71 Bnodes, and Resources tables will still exist.
72
73 "supports ( [ $feature ] )"
74 If $feature is specified, returns true if the feature is supported
75 by the store, false otherwise. If $feature is not specified,
76 returns a list of supported features.
77
78 "temporary_store"
79 "clear_restrictions"
80 Clear's the restrictions put on the binding of node types to the
81 different statement positions. By default, the subject position is
82 restricted to resources and blank nodes, and the predicate position
83 to only resources. Calling this method will allow any node type in
84 any statement position.
85
86 "get_statements ($subject, $predicate, $object [, $context] )"
87 Returns a stream object of all statements matching the specified
88 subject, predicate and objects. Any of the arguments may be undef
89 to match any value.
90
91 "get_pattern ( $bgp [, $context] )"
92 Returns a stream object of all bindings matching the specified
93 graph pattern.
94
95 "get_contexts"
96 Returns an RDF::Trine::Iterator over the RDF::Trine::Node objects
97 comprising the set of contexts of the stored quads.
98
99 "add_statement ( $statement [, $context] )"
100 Adds the specified $statement to the underlying model.
101
102 "remove_statement ( $statement [, $context])"
103 Removes the specified $statement from the underlying model.
104
105 "remove_statements ( $subject, $predicate, $object [, $context])"
106 Removes the specified $statement from the underlying model.
107
108 "count_statements ($subject, $predicate, $object)"
109 Returns a count of all the statements matching the specified
110 subject, predicate and objects. Any of the arguments may be undef
111 to match any value.
112
113 "add_uri ( $uri, $named, $format )"
114 Addsd the contents of the specified $uri to the model. If $named
115 is true, the data is added to the model using $uri as the named
116 context.
117
118 "add_string ( $data, $base_uri, $named, $format )"
119 Addsd the contents of $data to the model. If $named is true, the
120 data is added to the model using $base_uri as the named context.
121
122 "add_statement ( $statement )"
123 Adds the specified $statement to the underlying model.
124
125 "remove_statement ( $statement )"
126 Removes the specified $statement from the underlying model.
127
128 "variable_columns ( $var )"
129 Given a variable name, returns the set of column aliases that store
130 the values for the column (values for Literals, URIs, and Blank
131 Nodes).
132
133 "add_variable_values_joins"
134 Modifies the query by adding LEFT JOINs to the tables in the
135 database that contain the node values (for literals, resources, and
136 blank nodes).
137
138 "_mysql_hash ( $data )"
139 Returns a hash value for the supplied $data string. This value is
140 computed using the same algorithm that Redland's mysql storage
141 backend uses.
142
143 "_mysql_node_hash ( $node )"
144 Returns a hash value (computed by "_mysql_hash" for the supplied
145 $node. The hash value is based on the string value of the node and
146 the node type.
147
148 "statements_table"
149 Returns the name of the Statements table.
150
151 "statements_prefix"
152 Returns the prefix for the underlying Statements database table.
153
154 "set_statements_prefix ( $prefix )"
155 Sets the prefix for the underlying Statements database table.
156
157 "model_name"
158 Returns the name of the underlying model.
159
160 "make_private_predicate_view ( $prefix, @preds )"
161 "dbh"
162 Returns the underlying DBI database handle.
163
164 "init"
165 Creates the necessary tables in the underlying database.
166
168 Please report any bugs or feature requests to through the GitHub web
169 interface at <https://github.com/kasei/perlrdf/issues>.
170
172 Gregory Todd Williams "<gwilliams@cpan.org>"
173
175 Copyright (c) 2006-2012 Gregory Todd Williams. This program is free
176 software; you can redistribute it and/or modify it under the same terms
177 as Perl itself.
178
179
180
181perl v5.32.0 2020-07-28 RDF::Trine::Store::DBI(3)