info > DBI::DBD::SqlEngine

DBI::DBD::SqlEngine(3pUser Contributed Perl Documentation)

📖 NAME

DBI::DBD::SqlEngine - Base class for DBI drivers without their own SQL engine

🚀 Quick Reference

Use CaseCommandDescription
Create a new DBD driveruse base qw(DBI::DBD::SqlEngine);Inherit base class for SQL engine support
Set table metadata$dbh->{sql_meta} = { table => { col_names => [...] } }Pre-initialize table attributes
Choose SQL enginesetenv DBI_SQL_NANO 0 or load SQL::StatementSelect between nano and full SQL parser
Get table metadata$dbh->func( "sql_get_meta", $table, $attr )Retrieve a specific meta attribute
List available tables@tables = $dbh->func( "list_tables" )Return table names from data source

📋 SYNOPSIS

package DBD::myDriver;

use base qw(DBI::DBD::SqlEngine);

sub driver
{
    ...
    my $drh = $proto->SUPER::driver($attr);
    ...
    return $drh->{class};
}

package DBD::myDriver::dr;

@ISA = qw(DBI::DBD::SqlEngine::dr);

sub data_sources { ... }
...

package DBD::myDriver::db;

@ISA = qw(DBI::DBD::SqlEngine::db);

sub init_valid_attributes { ... }
sub init_default_attributes { ... }
sub set_versions { ... }
sub validate_STORE_attr { my ($dbh, $attrib, $value) = @_; ... }
sub validate_FETCH_attr { my ($dbh, $attrib) = @_; ... }
sub get_myd_versions { ... }
sub get_avail_tables { ... }

package DBD::myDriver::st;

@ISA = qw(DBI::DBD::SqlEngine::st);

sub FETCH { ... }
sub STORE { ... }

package DBD::myDriver::Statement;

@ISA = qw(DBI::DBD::SqlEngine::Statement);

sub open_table { ... }

package DBD::myDriver::Table;

@ISA = qw(DBI::DBD::SqlEngine::Table);

sub new { ... }

📝 DESCRIPTION

DBI::DBD::SqlEngine abstracts the usage of SQL engines from the DBD. DBD authors can concentrate on the data retrieval they want to provide.

It is strongly recommended that you read DBD::File::Developers and DBD::File::Roadmap, because many of the DBD::File API is provided by DBI::DBD::SqlEngine.

Currently the API of DBI::DBD::SqlEngine is experimental and will likely change in the near future to provide the table meta data basics like DBD::File.

DBI::DBD::SqlEngine expects that any driver in inheritance chain has a DBI prefix.

📊 Metadata

The following attributes are handled by DBI itself and not by DBI::DBD::SqlEngine, thus they all work as expected:

The following DBI attributes are handled by DBI::DBD::SqlEngine:

The following DBI attributes and methods are not supported:

DBI::DBD::SqlEngine specific attributes:

🔧 Driver private methods

📌 Default DBI methods

📌 Additional methods

The following methods are only available via their documented name when DBI::DBD::SQlEngine is used directly. Because this is only reasonable for testing purposes, the real names must be used instead. Those names can be computed by replacing the "sql_" in the method name with the driver prefix.

🔌 Extensibility

DBI::DBD::SqlEngine::TableSource

Provides data sources and table information on database driver and database handle level.

package DBI::DBD::SqlEngine::TableSource;

sub data_sources ($;$)
{
  my ( $class, $drh, $attrs ) = @_;
  ...
}

sub avail_tables
{
  my ( $class, $drh ) = @_;
  ...
}

The "data_sources" method is called when the user invokes any of the following:

The "avail_tables" method is called when the user invokes any of the following:

Every time where an "\%attr" argument can be specified, this "\%attr" object's "sql_table_source" attribute is preferred over the $dbh attribute or the driver default, e.g.:

@ary = DBI->data_sources("dbi:CSV:", {
  f_dir => "/your/csv/tables",
  sql_table_source => "DBD::File::Archive::Tar::TableSource",
});

When implementing such a DBD::File::Archive::Tar::TableSource class, remember to add correct attributes (including "sql_table_source" and "sql_data_source") to the returned DSN's.

DBI::DBD::SqlEngine::DataSource

Provides base functionality for dealing with tables. It is primarily designed for allowing transparent access to files on disk or already opened (file-)streams (e.g., for DBD::CSV). Derived classes shall be restricted to similar functionality, too.

package DBI::DBD::SqlEngine::DataSource;

sub complete_table_name ($$;$)
{
  my ( $self, $meta, $table, $respect_case ) = @_;
  ...
}

The method "complete_table_name" is called when first setting up the meta information for a table. For example:

SELECT user.id, user.name, user.shell FROM user WHERE ...

results in opening the table "user". First step of the table open process is completing the name. Let's imagine you're having a DBD::CSV handle with following settings:

$dbh->{sql_identifier_case} = SQL_IC_LOWER;
$dbh->{f_ext} = '.lst';
$dbh->{f_dir} = '/data/web/adrmgr';

Those settings will result in looking for files matching "[Uu][Ss][Ee][Rr](\.lst)?$" in "/data/web/adrmgr/". The scanning of the directory "/data/web/adrmgr/" and the pattern match check will be done in "DBD::File::DataSource::File" by the "complete_table_name" method.

If you intend to provide other sources of data streams than files, in addition to provide an appropriate "complete_table_name" method, a method to open the resource is required:

package DBI::DBD::SqlEngine::DataSource;

sub open_data ($)
{
  my ( $self, $meta, $attrs, $flags ) = @_;
  ...
}

After the method "open_data" has been run successfully, the table's meta information are in a state which allows the table's data accessor methods to fetch/store row information. Implementation details heavily depend on the table implementation, whereby the most famous is surely DBD::File::Table.

🔧 SQL ENGINES

DBI::DBD::SqlEngine currently supports two SQL engines: SQL::Statement and DBI::SQL::Nano::Statement_. DBI::SQL::Nano supports a very limited subset of SQL statements, but it might be faster for some very simple tasks. SQL::Statement in contrast supports a much larger subset of ANSI SQL.

To use SQL::Statement, you need at least version 1.401 of SQL::Statement and the environment variable "DBI_SQL_NANO" must not be set to a true value.

🆘 SUPPORT

You can find documentation for this module with the perldoc command.

perldoc DBI::DBD::SqlEngine

You can also look for information at:

❓ Where can I go for more help?

For questions about installation or usage, please ask on the dbi-dev AT perl.org mailing list.

If you have a bug report, patch or suggestion, please open a new report ticket on CPAN, if there is not already one for the issue you want to report. Of course, you can mail any of the module maintainers, but it is less likely to be missed if it is reported on RT.

Report tickets should contain a detailed description of the bug or enhancement request you want to report and at least an easy way to verify/reproduce the issue and any supplied fix. Patches are always welcome, too.

🙏 ACKNOWLEDGEMENTS

Thanks to Tim Bunce, Martin Evans and H.Merijn Brand for their continued support while developing DBD::File, DBD::DBM and DBD::AnyData. Their support, hints and feedback helped to design and implement this module.

👤 AUTHOR

This module is currently maintained by H.Merijn Brand < h.m.brand at xs4all.nl > and Jens Rehsack < rehsack at googlemail.com >

The original authors are Jochen Wiedmann and Jeff Zucker.

📄 COPYRIGHT AND LICENSE

 Copyright (C) 2009-2013 by H.Merijn Brand & Jens Rehsack
 Copyright (C) 2004-2009 by Jeff Zucker
 Copyright (C) 1998-2004 by Jochen Wiedmann

All rights reserved.

You may freely distribute and/or modify this module under the terms of either the GNU General Public License (GPL) or the Artistic License, as specified in the Perl README file.

🔗 SEE ALSO

DBI, DBD::File, DBD::AnyData and DBD::Sys.

DBI::DBD::SqlEngine
📖 NAME 🚀 Quick Reference 📋 SYNOPSIS 📝 DESCRIPTION
📊 Metadata 🔧 Driver private methods 🔌 Extensibility
🔧 SQL ENGINES 🆘 SUPPORT
❓ Where can I go for more help?
🙏 ACKNOWLEDGEMENTS 👤 AUTHOR 📄 COPYRIGHT AND LICENSE 🔗 SEE ALSO

Generated by phpman v4.9.26-5-g7740029 Author: Che Dong Under GNU General Public License
2026-08-14 21:38 @2600:1f28:365:80b0:4d23:66fa:c2bb:7bae
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!