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 | |
| 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')
| -rwxr-xr-x | meta-perl/recipes-perl/libdb/libdbd-sqlite-perl/sqlite-perl-test.pl | 69 | ||||
| -rw-r--r-- | meta-perl/recipes-perl/libdb/libdbd-sqlite-perl_1.40.bb | 39 |
2 files changed, 108 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" | ||
diff --git a/meta-perl/recipes-perl/libdb/libdbd-sqlite-perl_1.40.bb b/meta-perl/recipes-perl/libdb/libdbd-sqlite-perl_1.40.bb new file mode 100644 index 0000000000..fad03d8178 --- /dev/null +++ b/meta-perl/recipes-perl/libdb/libdbd-sqlite-perl_1.40.bb | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | SUMMARY = "A Perl DBI driver for SQLite" | ||
| 2 | DESCRIPTION = "DBD::SQLite is a Perl DBI driver for SQLite, that includes the entire \ | ||
| 3 | thing in the distribution. So in order to get a fast transaction capable \ | ||
| 4 | RDBMS working for your perl project you simply have to install this \ | ||
| 5 | module, and nothing else. \ | ||
| 6 | " | ||
| 7 | HOMEPAGE = "http://search.cpan.org/~ishigaki/DBD-SQLite/" | ||
| 8 | |||
| 9 | SECTION = "libs" | ||
| 10 | LICENSE = "Artistic-1.0 | GPL-1.0+" | ||
| 11 | DEPENDS += "libdbi-perl-native" | ||
| 12 | RDEPENDS_${PN} += "libdbi-perl \ | ||
| 13 | sqlite3 \ | ||
| 14 | perl-module-constant \ | ||
| 15 | perl-module-locale \ | ||
| 16 | perl-module-tie-hash \ | ||
| 17 | " | ||
| 18 | |||
| 19 | LIC_FILES_CHKSUM = "file://LICENSE;md5=1726e2117494ba3e13e1c3d93f795360" | ||
| 20 | |||
| 21 | SRC_URI = "http://search.cpan.org/CPAN/authors/id/I/IS/ISHIGAKI/DBD-SQLite-${PV}.tar.gz \ | ||
| 22 | file://sqlite-perl-test.pl \ | ||
| 23 | " | ||
| 24 | |||
| 25 | SRC_URI[md5sum] = "b9876882186499583428b14cf5c0e29c" | ||
| 26 | SRC_URI[sha256sum] = "21fb65e740b6265512c82232b4ad8f75c19ac84c216830112656274eb8e375fb" | ||
| 27 | |||
| 28 | S = "${WORKDIR}/DBD-SQLite-${PV}" | ||
| 29 | |||
| 30 | inherit cpan | ||
| 31 | |||
| 32 | BBCLASSEXTEND = "native" | ||
| 33 | |||
| 34 | do_install_append() { | ||
| 35 | if [ ${PERL_DBM_TEST} = "1" ]; then | ||
| 36 | install -m 755 -D ${WORKDIR}/sqlite-perl-test.pl ${D}/${bindir}/sqlite-perl-test.pl | ||
| 37 | fi | ||
| 38 | } | ||
| 39 | |||
