{
    "mode": "perldoc",
    "parameter": "DBI::DBD::Metadata",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/DBI%3A%3ADBD%3A%3AMetadata/json",
    "generated": "2026-05-30T19:10:58Z",
    "synopsis": "The idea is to extract metadata information from a good quality ODBC\ndriver and use it to generate code and data to use in your own DBI\ndriver for the same database.\nTo generate code to support the getinfo method:\nperl -MDBI::DBD::Metadata -e \"writegetinfopm('dbi:ODBC:dsn-name','user','pass','Driver')\"\nperl -MDBI::DBD::Metadata -e writegetinfopm dbi:ODBC:foodb username password Driver\nTo generate code to support the typeinfo method:\nperl -MDBI::DBD::Metadata -e \"writetypeinfopm('dbi:ODBC:dsn-name','user','pass','Driver')\"\nperl -MDBI::DBD::Metadata -e writetypeinfopm dbi:ODBC:dsn-name user pass Driver\nWhere \"dbi:ODBC:dsn-name\" is the connection to use to extract the data,\nand \"Driver\" is the name of the driver you want the code generated for\n(the driver name gets embedded into the output in numerous places).",
    "sections": {
        "NAME": {
            "content": "DBI::DBD::Metadata - Generate the code and data for some DBI metadata\nmethods\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "The idea is to extract metadata information from a good quality ODBC\ndriver and use it to generate code and data to use in your own DBI\ndriver for the same database.\n\nTo generate code to support the getinfo method:\n\nperl -MDBI::DBD::Metadata -e \"writegetinfopm('dbi:ODBC:dsn-name','user','pass','Driver')\"\n\nperl -MDBI::DBD::Metadata -e writegetinfopm dbi:ODBC:foodb username password Driver\n\nTo generate code to support the typeinfo method:\n\nperl -MDBI::DBD::Metadata -e \"writetypeinfopm('dbi:ODBC:dsn-name','user','pass','Driver')\"\n\nperl -MDBI::DBD::Metadata -e writetypeinfopm dbi:ODBC:dsn-name user pass Driver\n\nWhere \"dbi:ODBC:dsn-name\" is the connection to use to extract the data,\nand \"Driver\" is the name of the driver you want the code generated for\n(the driver name gets embedded into the output in numerous places).\n",
            "subsections": []
        },
        "Generating a GetInfo package for a driver": {
            "content": "The \"writegetinfopm\" in the DBI::DBD::Metadata module generates a\nDBD::Driver::GetInfo package on standard output.\n\nThis method generates a DBD::Driver::GetInfo package from the data\nsource you specified in the parameter list or in the environment\nvariable DBIDSN. DBD::Driver::GetInfo should help a DBD author\nimplement the DBI getinfo() method. Because you are just creating this\npackage, it is very unlikely that DBD::Driver already provides a good\nimplementation for getinfo(). Thus you will probably connect via\nDBD::ODBC.\n\nOnce you are sure that it is producing reasonably sane data, you should\ntypically redirect the standard output to lib/DBD/Driver/GetInfo.pm, and\nthen hand edit the result. Do not forget to update your Makefile.PL and\nMANIFEST to include this as an extra PM file that should be installed.\n\nIf you connect via DBD::ODBC, you should use version 0.38 or greater;\n\nPlease take a critical look at the data returned! ODBC drivers vary\ndramatically in their quality.\n\nThe generator assumes that most values are static and places these\nvalues directly in the %info hash. A few examples show the use of CODE\nreferences and the implementation via subroutines. It is very likely\nthat you will have to write additional subroutines for values depending\non the session state or server version, e.g. SQLDBMSVER.\n\nA possible implementation of DBD::Driver::db::getinfo() may look like:\n\nsub getinfo {\nmy($dbh, $infotype) = @;\nrequire DBD::Driver::GetInfo;\nmy $v = $DBD::Driver::GetInfo::info{int($infotype)};\n$v = $v->($dbh) if ref $v eq 'CODE';\nreturn $v;\n}\n\nPlease replace Driver (or \"<foo>\") with the name of your driver. Note\nthat this stub function is generated for you by writegetinfopm\nfunction, but you must manually transfer the code to Driver.pm.\n",
            "subsections": []
        },
        "Generating a TypeInfo package for a driver": {
            "content": "The \"writetypeinfopm\" function in the DBI::DBD::Metadata module\ngenerates on standard output the data needed for a driver's\ntypeinfoall method. It also provides default implementations of the\ntypeinfoall method for inclusion in the driver's main implementation\nfile.\n\nThe driver parameter is the name of the driver for which the methods\nwill be generated; for the sake of examples, this will be \"Driver\".\nTypically, the dsn parameter will be of the form \"dbi:ODBC:odbcdsn\",\nwhere the odbcdsn is a DSN for one of the driver's databases. The user\nand pass parameters are the other optional connection parameters that\nwill be provided to the DBI connect method.\n\nOnce you are sure that it is producing reasonably sane data, you should\ntypically redirect the standard output to lib/DBD/Driver/TypeInfo.pm,\nand then hand edit the result if necessary. Do not forget to update your\nMakefile.PL and MANIFEST to include this as an extra PM file that should\nbe installed.\n\nPlease take a critical look at the data returned! ODBC drivers vary\ndramatically in their quality.\n\nThe generator assumes that all the values are static and places these\nvalues directly in the %info hash.\n\nA possible implementation of DBD::Driver::typeinfoall() may look like:\n\nsub typeinfoall {\nmy ($dbh) = @;\nrequire DBD::Driver::TypeInfo;\nreturn [ @$DBD::Driver::TypeInfo::typeinfoall ];\n}\n\nPlease replace Driver (or \"<foo>\") with the name of your driver. Note\nthat this stub function is generated for you by the writetypeinfopm\nfunction, but you must manually transfer the code to Driver.pm.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "Jonathan Leffler <jleffler@us.ibm.com> (previously\n<jleffler@informix.com>), Jochen Wiedmann <joe@ispsoft.de>, Steffen\nGoeldner <sgoeldner@cpan.org>, and Tim Bunce <dbi-users@perl.org>.\n",
            "subsections": []
        }
    },
    "summary": "DBI::DBD::Metadata - Generate the code and data for some DBI metadata methods",
    "flags": [],
    "examples": [],
    "see_also": []
}