The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Sedna - Driver to connect on the Sedna XML database

SYNOPSIS

  use Sedna;
  my $conn = Sedna->connect($url,$dbname,$login,$pass);
  $conn->execute("for $x in collection('my-collection') return $x");
  while ($conn->next) {
    my ($buf, $xml);
    while ($conn->getData($buf, 512)) {
      $xml .= $buf;
    }
    say $xml;
  }

OVERVIEW

Sedna is a XML database and you interact with it using XQuery. This driver is a direct mapping of the C driver available in the Sedna distribution, but the code is brought here since they only provide a static build of the library.

This module will croak on failures, so error handling should be implemented in terms of eval.

METHODS

Sedna->connect($url, $dbname, $login, $password)

This method is used to stablish a new connection.

$conn->setConnectionAttr(%options)

This method can be used to set various connection attribute parameters. This method is a convenience method for each of the setConnectionAttr_* methods. Note that you should use the Sedna constants when you send the values for that attributes, even if the attribute looks simply as a boolean value.

$conn->getConnectionAttr(@options)

Returns a hash with the values for all the requested options. This is just a convenience method for each of the getConnectionAttr_* methods.

$conn->setConnectionAttr_AUTOCOMMIT($value)
$conn->getConnectionAttr_AUTOCOMMIT( )

Accessors for the autocommit setting for this connection. The possible values for this attribute are SEDNA_AUTOCOMMIT_ON and SEDNA_AUTOCOMMIT_OFF.

$conn->setConnectionAttr_SESSION_DIRECTORY($dir)
$conn->getConnectionAttr_SESSION_DIRECTORY( )

This attribute defines the local directory to be used as a base path for LOAD statements.

$conn->setConnectionAttr_DEBUG($value)
$conn->getConnectionAttr_DEBUG( )

This enables or disable debug messages of the driver. Possible values are SEDNA_DEBUG_ON and SEDNA_DEBUG_OFF.

$conn->setConnectionAttr_CONCURRENCY_TYPE($value)
$conn->getConnectionAttr_CONCURRENCY_TYPE( )

This define the nivel of concurrency control applied to this specific transaction. One of: SEDNA_READONLY_TRANSACTION and SEDNA_UPDATE_TRANSACTION.

$conn->setConnectionAttr_QUERY_EXEC_TIMEOUT($timeout)
$conn->getConnectionAttr_QUERY_EXEC_TIMEOUT( )

This defines the number of seconds to wait for an execution.

$conn->setConnectionAttr_MAX_RESULT_SIZE($size)
$conn->getConnectionAttr_MAX_RESULT_SIZE( )

This controls how much data is allowed to be returned by the server in bytes.

$conn->setConnectionAttr_LOG_AMMOUNT($value)
$conn->getConnectionAttr_LOG_AMMOUNT( )

This control how much log the transaction will produce. Values are SEDNA_LOG_FULL and SEDNA_LOG_LESS.

$conn->begin( )
$conn->commit( )
$conn->rollback( )

This three methods implement the transaction control.

$conn->connectionStatus( )

Returns the current connection status.

$conn->transactionStatus( )

Returns the current transaction status.

$conn->execute($query)

Sends the given query to the server and waits (blocking) for its return.

$conn->executeLong($file)

Sends the query stored in the given file and waits (blockign) for its return.

$conn->next( )

Returns true if there is another value available, and advance the cursor.

$conn->getItem( )

Returns the XML content for the current item in this connection (must be called after next.

$conn->getData($buf, $len)

Works like the read function, storing up to the requested length into the scalar buffer. Notice that this function will return octets, not characters, so you should deal with encoding yourself (including incomplete utf-8 characters).

$conn->loadData($xml, $doc, $coll)

Send the xml string to the server for storing using the given document id and optionally storing in a collection.

$conn->endLoadData( )

Send to the server the notice that you finished sending the data.

SEE ALSO

The development of the bindings is hosted at http://github.com/ruoso/sedna. It was based on the quick start guide at http://www.modis.ispras.ru/sedna/c-samples.html.

AUTHOR

Daniel Ruoso <daniel@ruoso.com>

COPYRIGHT AND LICENSE

Copyright (C) 2010 by Daniel Ruoso

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.

The code for the C driver is embeded into this distribution and is subject to the Apache License.