Perl + SQLite

Source: Internet
Author: User
Tags sqlite database

1. Common cmds

SQLite is a small embedded relational database that can be embedded into almost all programming languages, especially C, C ++, PHP, Perl, etc. This section describes how to use Perl to connect to and operate the SQLite database.

Use dBi; # Perl is used to operate the SQLite module. This module is enough to use strict; # This sentence must be added for beginners to write the use warnings statement strictly required; Main: {my $ dbargs = {autocommit => 0, # Use the event printerror => 1}; # connect to the database my $ DBH = DBI-> connect ("DBI: SQLite: dbname = test. DB "," "," ", $ dbargs); # create a table $ DBH-> do (" create table test (ID int primary key, age, name )"); # insert data $ DBH-> do ("insert into test values (null, '34', 'Liu Qiang '"); # update data $ DBH-> do ("Update test set age = '33' where name = 'Liu Qiang '"); # delete data $ DBH-> do ("delete from test where name = 'Liu Qiang '"); # query data my $ SQL = "select * from test "; my $ dbconn = $ DBH-> prepare ($ SQL); $ dbconn-> execute (); my (@ row_ary, $ CC, $ BB, $ dd ); while (@ row_ary = $ dbconn-> fetchrow_array) {My ($ CC, $ BB, $ dd) = @ row_ary; print "Table Test content is \ n "; print "\ t @ row_ary \ n ";}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.