Home > Database > Mysql Tutorial > body text

如何用Perl访问SQLite数据库

WBOY
Release: 2016-06-07 15:53:25
Original
1100 people have browsed it

SQLite是一个零配置、无服务端、基于文件的事务型数据库系统。由于它的轻量级,自包含和紧凑的设计,所以当你想要集成数据库到你

SQLite是一个零配置、无服务端、基于文件的事务型数据库系统。由于它的轻量级,自包含和紧凑的设计,所以当你想要集成数据库到你的程序中时,SQLite是一个非常不错的选择。在这篇文章中,我会展示如何用Perl脚本来创建和访问SQLite数据库。我演示的Perl代码片段是完整的,所以你可以很简单地修改并集成到你的项目中。

如何用Perl访问SQLite数据库

 

访问SQLite的准备

我会使用SQLite DBI Perl驱动来连接到SQLite3。因此你需要在Linux中安装它(和SQLite3一起)。

Debian、 Ubuntu 或者 Linux Mint

CentOS、 Fedora 或者 RHEL

安装后,,你可以检查SQLite驱动可以通过下面的脚本访问到。

如果你运行脚本,你应该会看见下面的输出。

 

Perl SQLite 访问示例

下面就是Perl访问SQLite的示例。这个Perl脚本会演示下面这些SQLite数据库的常规管理。

上面的Perl脚本运行成功后会创建一个叫“xmodulo.db”的数据库文件,并会有下面的输出。

 

错误定位

如果你尝试没有安装SQLite DBI驱动的情况下使用Perl访问SQLite的话,你会遇到下面的错误。你必须按开始说的安装DBI驱动。

  • Can't locate DBI.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./script.pl line 3.
  • BEGIN failed--compilation aborted at ./script.pl line 3.
  • SQLite3 安装、基本操作

    Ubuntu 12.04下SQLite数据库简单应用

    Ubuntu 12.04下安装 SQLite及其使用方法

    SQLite 数据库入门基础教程

    SQLite 的详细介绍:请点这里
    SQLite 的下载地址:请点这里

    via:

    作者:Dan Nanni 译者:geekpi 校对:wxy

    本文由 LCTT 原创翻译,Linux中国 荣誉推出

    本文永久更新链接地址

    Related labels:
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!