{
    "mode": "perldoc",
    "parameter": "DBI::DBD::SqlEngine",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/DBI%3A%3ADBD%3A%3ASqlEngine/json",
    "generated": "2026-06-15T23:02:18Z",
    "synopsis": "package DBD::myDriver;\nuse base qw(DBI::DBD::SqlEngine);\nsub driver\n{\n...\nmy $drh = $proto->SUPER::driver($attr);\n...\nreturn $drh->{class};\n}\npackage DBD::myDriver::dr;\n@ISA = qw(DBI::DBD::SqlEngine::dr);\nsub datasources { ... }\n...\npackage DBD::myDriver::db;\n@ISA = qw(DBI::DBD::SqlEngine::db);\nsub initvalidattributes { ... }\nsub initdefaultattributes { ... }\nsub setversions { ... }\nsub validateSTOREattr { my ($dbh, $attrib, $value) = @; ... }\nsub validateFETCHattr { my ($dbh, $attrib) = @; ... }\nsub getmydversions { ... }\nsub getavailtables { ... }\npackage DBD::myDriver::st;\n@ISA = qw(DBI::DBD::SqlEngine::st);\nsub FETCH { ... }\nsub STORE { ... }\npackage DBD::myDriver::Statement;\n@ISA = qw(DBI::DBD::SqlEngine::Statement);\nsub opentable { ... }\npackage DBD::myDriver::Table;\n@ISA = qw(DBI::DBD::SqlEngine::Table);\nsub new { ... }",
    "sections": {
        "NAME": {
            "content": "DBI::DBD::SqlEngine - Base class for DBI drivers without their own SQL engine\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "package DBD::myDriver;\n\nuse base qw(DBI::DBD::SqlEngine);\n\nsub driver\n{\n...\nmy $drh = $proto->SUPER::driver($attr);\n...\nreturn $drh->{class};\n}\n\npackage DBD::myDriver::dr;\n\n@ISA = qw(DBI::DBD::SqlEngine::dr);\n\nsub datasources { ... }\n...\n\npackage DBD::myDriver::db;\n\n@ISA = qw(DBI::DBD::SqlEngine::db);\n\nsub initvalidattributes { ... }\nsub initdefaultattributes { ... }\nsub setversions { ... }\nsub validateSTOREattr { my ($dbh, $attrib, $value) = @; ... }\nsub validateFETCHattr { my ($dbh, $attrib) = @; ... }\nsub getmydversions { ... }\nsub getavailtables { ... }\n\npackage DBD::myDriver::st;\n\n@ISA = qw(DBI::DBD::SqlEngine::st);\n\nsub FETCH { ... }\nsub STORE { ... }\n\npackage DBD::myDriver::Statement;\n\n@ISA = qw(DBI::DBD::SqlEngine::Statement);\n\nsub opentable { ... }\n\npackage DBD::myDriver::Table;\n\n@ISA = qw(DBI::DBD::SqlEngine::Table);\n\nsub new { ... }\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "DBI::DBD::SqlEngine abstracts the usage of SQL engines from the DBD. DBD authors can concentrate\non the data retrieval they want to provide.\n\nIt is strongly recommended that you read DBD::File::Developers and DBD::File::Roadmap, because\nmany of the DBD::File API is provided by DBI::DBD::SqlEngine.\n\nCurrently the API of DBI::DBD::SqlEngine is experimental and will likely change in the near\nfuture to provide the table meta data basics like DBD::File.\n\nDBI::DBD::SqlEngine expects that any driver in inheritance chain has a DBI prefix.\n",
            "subsections": [
                {
                    "name": "Metadata",
                    "content": "The following attributes are handled by DBI itself and not by DBI::DBD::SqlEngine, thus they all\nwork as expected:\n\nActive\nActiveKids\nCachedKids\nCompatMode             (Not used)\nInactiveDestroy\nAutoInactiveDestroy\nKids\nPrintError\nRaiseError\nWarn                   (Not used)\n\nThe following DBI attributes are handled by DBI::DBD::SqlEngine:\nAutoCommit\nAlways on.\n\nChopBlanks\nWorks.\n\nNUMOFFIELDS\nValid after \"$sth->execute\".\n\nNUMOFPARAMS\nValid after \"$sth->prepare\".\n\nNAME\nValid after \"$sth->execute\"; probably undef for Non-Select statements.\n\nNULLABLE\nNot really working, always returns an array ref of ones, as DBD::CSV does not verify input data.\nValid after \"$sth->execute\"; undef for non-select statements.\n\nThe following DBI attributes and methods are not supported:\nbindparaminout\nCursorName\nLongReadLen\nLongTruncOk\n\nDBI::DBD::SqlEngine specific attributes\nIn addition to the DBI attributes, you can use the following dbh attributes:\n\nsqlengineversion\nContains the module version of this driver (readonly)\n\nsqlnanoversion\nContains the module version of DBI::SQL::Nano (readonly)\n\nsqlstatementversion\nContains the module version of SQL::Statement, if available (readonly)\n\nsqlhandler\nContains the SQL Statement engine, either DBI::SQL::Nano or SQL::Statement (readonly).\n\nsqlparserobject\nContains an instantiated instance of SQL::Parser (readonly). This is filled when used first time\n(only when used with SQL::Statement).\n\nsqlspongedriver\nContains an internally used DBD::Sponge handle (readonly).\n\nsqlvalidattrs\nContains the list of valid attributes for each DBI::DBD::SqlEngine based driver (readonly).\n\nsqlreadonlyattrs\nContains the list of those attributes which are readonly (readonly).\n\nsqlidentifiercase\nContains how DBI::DBD::SqlEngine deals with non-quoted SQL identifiers:\n\n* SQLICUPPER (1) means all identifiers are internally converted\ninto upper-cased pendants\n* SQLICLOWER (2) means all identifiers are internally converted\ninto lower-cased pendants\n* SQLICMIXED (4) means all identifiers are taken as they are\n\nThese conversions happen if (and only if) no existing identifier matches. Once existing\nidentifier is used as known.\n\nThe SQL statement execution classes doesn't have to care, so don't expect \"sqlidentifiercase\"\naffects column names in statements like\n\nSELECT * FROM foo\n\nsqlquotedidentifiercase\nContains how DBI::DBD::SqlEngine deals with quoted SQL identifiers (readonly). It's fixated to\nSQLICSENSITIVE (3), which is interpreted as SQLICMIXED.\n\nsqlflags\nContains additional flags to instantiate an SQL::Parser. Because an SQL::Parser is instantiated\nonly once, it's recommended to set this flag before any statement is executed.\n\nsqldialect\nControls the dialect understood by SQL::Parser. Possible values (delivery state of\nSQL::Statement):\n\n* ANSI\n* CSV\n* AnyData\n\nDefaults to \"CSV\". Because an SQL::Parser is instantiated only once and SQL::Parser doesn't\nallow one to modify the dialect once instantiated, it's strongly recommended to set this flag\nbefore any statement is executed (best place is connect attribute hash).\n\nsqlengineingofer\nThis value has a true value in case of this driver is operated via DBD::Gofer. The impact of\nbeing operated via Gofer is a read-only driver (not read-only databases!), so you cannot modify\nany attributes later - neither any table settings. But you won't get an error in cases you\nmodify table attributes, so please carefully watch \"sqlengineingofer\".\n\nsqlmeta\nPrivate data area which contains information about the tables this module handles. Table meta\ndata might not be available until the table has been accessed for the first time e.g., by\nissuing a select on it however it is possible to pre-initialize attributes for each table you\nuse.\n\nDBI::DBD::SqlEngine recognizes the (public) attributes \"colnames\", \"tablename\", \"readonly\",\n\"sqldatasource\" and \"sqlidentifiercase\". Be very careful when modifying attributes you do\nnot know, the consequence might be a destroyed or corrupted table.\n\nWhile \"sqlmeta\" is a private and readonly attribute (which means, you cannot modify it's\nvalues), derived drivers might provide restricted write access through another attribute. Well\nknown accessors are \"csvtables\" for DBD::CSV, \"adtables\" for DBD::AnyData and \"dbmtables\" for\nDBD::DBM.\n\nsqltablesource\nControls the class which will be used for fetching available tables.\n\nSee \"DBI::DBD::SqlEngine::TableSource\" for details.\n\nsqldatasource\nContains the class name to be used for opening tables.\n\nSee \"DBI::DBD::SqlEngine::DataSource\" for details.\n"
                },
                {
                    "name": "Driver private methods",
                    "content": "Default DBI methods\ndatasources\nThe \"datasources\" method returns a list of subdirectories of the current directory in the form\n\"dbi:CSV:fdir=$dirname\".\n\nIf you want to read the subdirectories of another directory, use\n\nmy ($drh)  = DBI->installdriver (\"CSV\");\nmy (@list) = $drh->datasources (fdir => \"/usr/local/csvdata\");\n\nlisttables\nThis method returns a list of file names inside $dbh->{fdir}. Example:\n\nmy ($dbh)  = DBI->connect (\"dbi:CSV:fdir=/usr/local/csvdata\");\nmy (@list) = $dbh->func (\"listtables\");\n\nNote that the list includes all files contained in the directory, even those that have non-valid\ntable names, from the view of SQL.\n\nAdditional methods\nThe following methods are only available via their documented name when DBI::DBD::SQlEngine is\nused directly. Because this is only reasonable for testing purposes, the real names must be used\ninstead. Those names can be computed by replacing the \"sql\" in the method name with the driver\nprefix.\n\nsqlversions\nSignature:\n\nsub sqlversions (;$) {\nmy ($tablename) = @;\n$tablename ||= \".\";\n...\n}\n\nReturns the versions of the driver, including the DBI version, the Perl version, DBI::PurePerl\nversion (if DBI::PurePerl is active) and the version of the SQL engine in use.\n\nmy $dbh = DBI->connect (\"dbi:File:\");\nmy $sqlversions = $dbh->func( \"sqlversions\" );\nprint \"$sqlversions\\n\";\nEND\n# DBI::DBD::SqlEngine  0.05 using SQL::Statement 1.402\n# DBI                  1.623\n# OS                   netbsd (6.99.12)\n# Perl                 5.016002 (x8664-netbsd-thread-multi)\n\nCalled in list context, sqlversions will return an array containing each line as single entry.\n\nSome drivers might use the optional (table name) argument and modify version information related\nto the table (e.g. DBD::DBM provides storage backend information for the requested table, when\nit has a table name).\n\nsqlgetmeta\nSignature:\n\nsub sqlgetmeta ($$)\n{\nmy ($tablename, $attrib) = @;\n...\n}\n\nReturns the value of a meta attribute set for a specific table, if any. See sqlmeta for the\npossible attributes.\n\nA table name of \".\" (single dot) is interpreted as the default table. This will retrieve the\nappropriate attribute globally from the dbh. This has the same restrictions as\n\"$dbh->{$attrib}\".\n\nsqlsetmeta\nSignature:\n\nsub sqlsetmeta ($$$)\n{\nmy ($tablename, $attrib, $value) = @;\n...\n}\n\nSets the value of a meta attribute set for a specific table. See sqlmeta for the possible\nattributes.\n\nA table name of \".\" (single dot) is interpreted as the default table which will set the\nspecified attribute globally for the dbh. This has the same restrictions as \"$dbh->{$attrib} =\n$value\".\n\nsqlclearmeta\nSignature:\n\nsub sqlclearmeta ($)\n{\nmy ($tablename) = @;\n...\n}\n\nClears the table specific meta information in the private storage of the dbh.\n"
                },
                {
                    "name": "Extensibility",
                    "content": "DBI::DBD::SqlEngine::TableSource\nProvides data sources and table information on database driver and database handle level.\n\npackage DBI::DBD::SqlEngine::TableSource;\n\nsub datasources ($;$)\n{\nmy ( $class, $drh, $attrs ) = @;\n...\n}\n\nsub availtables\n{\nmy ( $class, $drh ) = @;\n...\n}\n\nThe \"datasources\" method is called when the user invokes any of the following:\n\n@ary = DBI->datasources($driver);\n@ary = DBI->datasources($driver, \\%attr);\n\n@ary = $dbh->datasources();\n@ary = $dbh->datasources(\\%attr);\n\nThe \"availtables\" method is called when the user invokes any of the following:\n\n@names = $dbh->tables( $catalog, $schema, $table, $type );\n\n$sth = $dbh->tableinfo( $catalog, $schema, $table, $type );\n$sth = $dbh->tableinfo( $catalog, $schema, $table, $type, \\%attr );\n\n$dbh->func( \"listtables\" );\n\nEvery time where an \"\\%attr\" argument can be specified, this \"\\%attr\" object's\n\"sqltablesource\" attribute is preferred over the $dbh attribute or the driver default, eg.\n\n@ary = DBI->datasources(\"dbi:CSV:\", {\nfdir => \"/your/csv/tables\",\n# note: this class doesn't comes with DBI\nsqltablesource => \"DBD::File::Archive::Tar::TableSource\",\n# scan tarballs instead of directories\n});\n\nWhen you're going to implement such a DBD::File::Archive::Tar::TableSource class, remember to\nadd correct attributes (including \"sqltablesource\" and \"sqldatasource\") to the returned\nDSN's.\n\nDBI::DBD::SqlEngine::DataSource\nProvides base functionality for dealing with tables. It is primarily designed for allowing\ntransparent access to files on disk or already opened (file-)streams (eg. for DBD::CSV).\n\nDerived classes shall be restricted to similar functionality, too (eg. opening streams from an\narchive, transparently compress/uncompress log files before parsing them,\n\npackage DBI::DBD::SqlEngine::DataSource;\n\nsub completetablename ($$;$)\n{\nmy ( $self, $meta, $table, $respectcase ) = @;\n...\n}\n\nThe method \"completetablename\" is called when first setting up the *meta information* for a\ntable:\n\n\"SELECT user.id, user.name, user.shell FROM user WHERE ...\"\n\nresults in opening the table \"user\". First step of the table open process is completing the\nname. Let's imagine you're having a DBD::CSV handle with following settings:\n\n$dbh->{sqlidentifiercase} = SQLICLOWER;\n$dbh->{fext} = '.lst';\n$dbh->{fdir} = '/data/web/adrmgr';\n\nThose settings will result in looking for files matching \"[Uu][Ss][Ee][Rr](\\.lst)?$\" in\n\"/data/web/adrmgr/\". The scanning of the directory \"/data/web/adrmgr/\" and the pattern match\ncheck will be done in \"DBD::File::DataSource::File\" by the \"completetablename\" method.\n\nIf you intend to provide other sources of data streams than files, in addition to provide an\nappropriate \"completetablename\" method, a method to open the resource is required:\n\npackage DBI::DBD::SqlEngine::DataSource;\n\nsub opendata ($)\n{\nmy ( $self, $meta, $attrs, $flags ) = @;\n...\n}\n\nAfter the method \"opendata\" has been run successfully, the table's meta information are in a\nstate which allowes the table's data accessor methods will be able to fetch/store row\ninformation. Implementation details heavily depends on the table implementation, whereby the\nmost famous is surely DBD::File::Table.\n"
                }
            ]
        },
        "SQL ENGINES": {
            "content": "DBI::DBD::SqlEngine currently supports two SQL engines: SQL::Statement and\nDBI::SQL::Nano::Statement. DBI::SQL::Nano supports a *very* limited subset of SQL statements,\nbut it might be faster for some very simple tasks. SQL::Statement in contrast supports a much\nlarger subset of ANSI SQL.\n\nTo use SQL::Statement, you need at least version 1.401 of SQL::Statement and the environment\nvariable \"DBISQLNANO\" must not be set to a true value.\n",
            "subsections": []
        },
        "SUPPORT": {
            "content": "You can find documentation for this module with the perldoc command.\n\nperldoc DBI::DBD::SqlEngine\n\nYou can also look for information at:\n\n*   RT: CPAN's request tracker\n\n<http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBI>\n<http://rt.cpan.org/NoAuth/Bugs.html?Dist=SQL-Statement>\n\n*   AnnoCPAN: Annotated CPAN documentation\n\n<http://annocpan.org/dist/DBI> <http://annocpan.org/dist/SQL-Statement>\n\n*   CPAN Ratings\n\n<http://cpanratings.perl.org/d/DBI>\n\n*   Search CPAN\n\n<http://search.cpan.org/dist/DBI/>\n\nWhere can I go for more help?\nFor questions about installation or usage, please ask on the dbi-dev@perl.org mailing list.\n\nIf you have a bug report, patch or suggestion, please open a new report ticket on CPAN, if there\nis not already one for the issue you want to report. Of course, you can mail any of the module\nmaintainers, but it is less likely to be missed if it is reported on RT.\n\nReport tickets should contain a detailed description of the bug or enhancement request you want\nto report and at least an easy way to verify/reproduce the issue and any supplied fix. Patches\nare always welcome, too.\n",
            "subsections": []
        },
        "ACKNOWLEDGEMENTS": {
            "content": "Thanks to Tim Bunce, Martin Evans and H.Merijn Brand for their continued support while\ndeveloping DBD::File, DBD::DBM and DBD::AnyData. Their support, hints and feedback helped to\ndesign and implement this module.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "This module is currently maintained by\n\nH.Merijn Brand < h.m.brand at xs4all.nl > and Jens Rehsack < rehsack at googlemail.com >\n\nThe original authors are Jochen Wiedmann and Jeff Zucker.\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "Copyright (C) 2009-2013 by H.Merijn Brand & Jens Rehsack\nCopyright (C) 2004-2009 by Jeff Zucker\nCopyright (C) 1998-2004 by Jochen Wiedmann\n\nAll rights reserved.\n\nYou may freely distribute and/or modify this module under the terms of either the GNU General\nPublic License (GPL) or the Artistic License, as specified in the Perl README file.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "DBI, DBD::File, DBD::AnyData and DBD::Sys.\n",
            "subsections": []
        }
    },
    "summary": "DBI::DBD::SqlEngine - Base class for DBI drivers without their own SQL engine",
    "flags": [],
    "examples": [],
    "see_also": []
}