The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Sedna - Driver to connect on the Sedna XML database


  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;


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.


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

This method is used to stablish a new connection.


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.


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

$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->getConnectionAttr_SESSION_DIRECTORY( )

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

$conn->getConnectionAttr_DEBUG( )

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

$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->getConnectionAttr_QUERY_EXEC_TIMEOUT( )

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

$conn->getConnectionAttr_MAX_RESULT_SIZE( )

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

$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.


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


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->getData($buf, $len)

Works like the read function, storing up to the requested length into the scalar buffer.

$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.


The development of the bindings is hosted at It was based on the quick start guide at


Daniel Ruoso <>


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.