Perl DBI 模块提供了一个通用的数据库访问接口。你可以编写一个 DBI 脚本,使其可以在不更改的情况下与许多不同的数据库引擎一起使用。要将 DBI 与 MySQL 一起使用,请安装以下内容:The Perl DBI module provides a generic interface
for database access. You can write a DBI script that works with many
different database engines without change. To use DBI with MySQL,
install the following:
DBI模块。TheDBImodule.DBD::mysql模块。 这是 Perl 的数据库驱动程序 (DBD) 模块。TheDBD::mysqlmodule. This is the DataBase Driver (DBD) module for Perl.可选地,你可以使用适用于任何其他类型数据库服务器的 DBD 模块。Optionally, the DBD module for any other type of database server you want to access.
Perl DBI 是推荐的 Perl 接口。它取代了一个较旧的接口 mysqlperl,该接口应被视为过时。Perl DBI is the recommended Perl interface. It replaces an older
interface called mysqlperl, which should be
considered obsolete.
这些部分包含有关在 Perl 中使用 MySQL 以及使用 Perl 编写 MySQL 应用程序的信息:These sections contain information about using Perl with MySQL and writing MySQL applications in Perl:
关于 Perl DBI 支持的安装说明,请参见 第 2.10 节,“Perl 安装说明”。For installation instructions for Perl DBI support, see Section 2.10, “Perl Installation Notes”.
有关从选项文件读取选项的示例,请参见 第 7.8.4 节,“在多服务器环境中使用客户端程序”。For an example of reading options from option files, see Section 7.8.4, “Using Client Programs in a Multiple-Server Environment”.
有关安全编码技巧,请参阅 第 8.1.1 节,“安全指南”。For secure coding tips, see Section 8.1.1, “Security Guidelines”.
有关调试技巧,请参阅 第 7.9.1.4 节,“在 gdb 下调试 mysqld”。For debugging tips, see Section 7.9.1.4, “Debugging mysqld under gdb”.
有关一些特定于 Perl 的环境变量,请参阅 第 6.9 节,“环境变量”。For some Perl-specific environment variables, see Section 6.9, “Environment Variables”.
有关在 macOS 上运行的注意事项,请参阅 第 2.4 节,“在 macOS 上安装 MySQL”。For considerations for running on macOS, see Section 2.4, “Installing MySQL on macOS”.
有关引用字符串字面量的方法,请参阅 第 11.1.1 节,“字符串字面量”。For ways to quote string literals, see Section 11.1.1, “String Literals”.
DBI 信息可通过命令行、在线或纸质形式获取:DBI information is available at the command line, online, or in printed form:
一旦你安装了
DBI和DBD::mysql模块,你可以使用perldoc命令在命令行中获取它们的信息:Once you have theDBIandDBD::mysqlmodules installed, you can get information about them at the command line with theperldoccommand:$>
perldoc DBI$>perldoc DBI::FAQ$>perldoc DBD::mysql你也可以使用
pod2man、pod2html等将这些信息转换成其他格式。You can also usepod2man,pod2html, and so on to translate this information into other formats.有关 Perl DBI 的在线信息,请访问 DBI 网站,http://dbi.perl.org/。该网站主持一个通用的 DBI 邮件列表。For online information about Perl DBI, visit the DBI website, http://dbi.perl.org/. That site hosts a general DBI mailing list.
有关印刷信息,官方 DBI 书籍是 Programming the Perl DBI(Alligator Descartes 和 Tim Bunce 著,O'Reilly & Associates,2000 年)。有关该书的信息可在 DBI 网站获取,http://dbi.perl.org/。For printed information, the official DBI book is Programming the Perl DBI (Alligator Descartes and Tim Bunce, O'Reilly & Associates, 2000). Information about the book is available at the DBI website, http://dbi.perl.org/.