diff options
author | Hongxu Jia <hongxu.jia@windriver.com> | 2013-08-12 08:00:21 +0000 |
---|---|---|
committer | Martin Jansa <Martin.Jansa@gmail.com> | 2013-08-16 12:58:30 +0200 |
commit | 5f78d37f9d28d2b6aff6993f3b3d050a0f5cfb90 (patch) | |
tree | ef38aa06c3da1dfd3aacc4ac5270926878953bc9 /meta-perl/recipes-perl/libdb/libdbd-sqlite-perl/sqlite-perl-test.pl | |
parent | f89374806bbe26cd367b22043b15e16b758a0d67 (diff) | |
download | meta-openembedded-5f78d37f9d28d2b6aff6993f3b3d050a0f5cfb90.tar.gz |
libdbd-sqlite-perl: add version 1.40
DBD::SQLite is a Perl DBI driver for SQLite, that includes the entire
thing in the distribution. So in order to get a fast transaction capable
RDBMS working for your perl project you simply have to install this
module, and nothing else.
There is a perl script for test, while variable PERL_DBM_TEST is assigned
the value '1', the script will be added, and you could run the script to
test whether DBD::SQLite is working properly.
[YOCTO #4128]
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Diffstat (limited to 'meta-perl/recipes-perl/libdb/libdbd-sqlite-perl/sqlite-perl-test.pl')
-rwxr-xr-x | meta-perl/recipes-perl/libdb/libdbd-sqlite-perl/sqlite-perl-test.pl | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/meta-perl/recipes-perl/libdb/libdbd-sqlite-perl/sqlite-perl-test.pl b/meta-perl/recipes-perl/libdb/libdbd-sqlite-perl/sqlite-perl-test.pl new file mode 100755 index 0000000000..40f5916f58 --- /dev/null +++ b/meta-perl/recipes-perl/libdb/libdbd-sqlite-perl/sqlite-perl-test.pl | |||
@@ -0,0 +1,69 @@ | |||
1 | #! /usr/bin/env perl | ||
2 | # | ||
3 | # This program is free software; you can redistribute it and/or modify | ||
4 | # it under the terms of the GNU General Public License as published by | ||
5 | # the Free Software Foundation; either version 2 of the License, or | ||
6 | # (at your option) any later version. | ||
7 | # | ||
8 | # This program is distributed in the hope that it will be useful, | ||
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | # GNU General Public License for more details. | ||
12 | # | ||
13 | # You should have received a copy of the GNU General Public License | ||
14 | # along with this program; if not, write to the Free Software Foundation. | ||
15 | # | ||
16 | # Copyright (C) 2013 Wind River Systems, Inc. | ||
17 | # | ||
18 | # - It tests DBI and DBD::SQLite could work correctly which means one could | ||
19 | # manipulate sqlite database in perl | ||
20 | # - The test includes create/insert/update/delete/select, the five important | ||
21 | # things one can do with a table | ||
22 | use DBI; | ||
23 | |||
24 | sub execute_sql { | ||
25 | my $dbh = $_[0]; | ||
26 | my $sql = $_[1]; | ||
27 | my $sth = $dbh->prepare($sql) | ||
28 | or die "Couldn't prepare statement: " . $dbh->errstr; | ||
29 | $sth->execute(); | ||
30 | print "$sql\n"; | ||
31 | return $sth; | ||
32 | } | ||
33 | |||
34 | sub select_all { | ||
35 | my $dbh = $_[0]; | ||
36 | my $table = $_[1]; | ||
37 | my $sth = &execute_sql($dbh, "Select * from $table"); | ||
38 | |||
39 | print "-----------------------------------\n"; | ||
40 | while (@data = $sth->fetchrow_array()) { | ||
41 | my $name = $data[0]; | ||
42 | my $id = $data[1]; | ||
43 | print "$name: $id\n"; | ||
44 | } | ||
45 | print "\n"; | ||
46 | |||
47 | $sth->finish; | ||
48 | return $sth; | ||
49 | } | ||
50 | |||
51 | # A private, temporary in-memory database is created for the connection. | ||
52 | # This in-memory database will vanish when the database connection is | ||
53 | # closed. It is handy for your library tests. | ||
54 | my $dbfile = ":memory:"; | ||
55 | my $dbh = DBI->connect("DBI:SQLite:dbname=$dbfile","","") | ||
56 | or die "Couldn't connect to database: " . DBI->errstr; | ||
57 | print "Connect to SQLite's in-memory database\n"; | ||
58 | |||
59 | &execute_sql($dbh, "Create table tbl1(name varchar(10), id smallint)"); | ||
60 | &execute_sql($dbh, "Insert into tbl1 values('yocto',10)"); | ||
61 | &execute_sql($dbh, "Insert into tbl1 values('windriver', 20)"); | ||
62 | &select_all($dbh, "tbl1"); | ||
63 | |||
64 | &execute_sql($dbh, "Update tbl1 set name = 'oe-core' where id = 10"); | ||
65 | &execute_sql($dbh, "Delete from tbl1 where id = 20"); | ||
66 | &select_all($dbh, "tbl1"); | ||
67 | |||
68 | $dbh->disconnect; | ||
69 | print "Test Success\n" | ||