NNexus::DB - DBI interface for NNexus, provides one DBI handle per NNexus::DB object.


  use NNexus::DB;
  $db = NNexus::DB(dbuser=>'nnexus',dbpass=>'pass',dbname=>"nnexus",dbhost=>"localhost", dbms=>"mysql");
  $connection_alive = $db->ping;
  $statement_handle = $db->prepare('DBI sql statement');
  $db->execute('DBI sql statement');
  $disconnect_successful = $db->done;


Interface to DBI's SQL logic. Provides an Object-oriented approach, where each NNexus::DB object contains a single DBI handle, together with a cache of prepared statements.

The documentation assumes basic familiarity with DBI.


$db = NNexus::Job->new(%options);

Creates a new NNexus::DB object. Required options are dbuser, dbpass, dbname, dbhost and dbms, so that the database connection can be successfully created.

$response = $db->DBI_handle_command;

The NNexus::DB methods are interfaces to their counterparts in DBI, with the addition of a query cache and a safety mechanism that auto-vivifies the connection when needed.

$sth = $db->safe;

The safe adverb returns a DBI handle, taking extra care that the handle is properly connected to the respective DB backend. While you could take the DBI handle and use it directly (it is the return value of the safe method), avoid that approach.

Instead, always invoke DBI commands through the NNexus::DB object or explicitly use the safe adverb to get a handle, e.g. $db-<gtexecute>, $db-<gtprepare> or $sth = $db-<gtsafe> The cache of prepared statements is also rejuvenated whenever a new DBI handle is auto-created.

$disconnect_successful = $db->done;

Disconnects from the backend and destroys the DBI handle. Note that the cache of prepared statements will be rejuvenated when a new DBI handle is initialized.

$statement_handle = $db->prepare;

Cached preparation of SQL statements. Internally uses the safe adverb, to ensure robustness. Each SQL query and its DBI statement handle is cached, to avoid multiple prepare calls on the same query string.


NNexus::DB::API, DBI


Deyan Ginev <>


 Research software, produced as part of work done by
 the KWARC group at Jacobs University Bremen.
 Released under the MIT license (MIT)