forked from pool/perl-Mojo-SQLite
Accepting request 624677 from devel:languages:perl
OBS-URL: https://build.opensuse.org/request/show/624677 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/perl-Mojo-SQLite?expand=0&rev=7
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7fa9960e682dee80c025677ffdc80963c541cf8a224ceda030422ccbfad87f6f
|
||||
size 41355
|
||||
3
Mojo-SQLite-3.001.tar.gz
Normal file
3
Mojo-SQLite-3.001.tar.gz
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:04b790d65b2a2d9fd1eaad52a72055c46f61aa3cad09bbe959ce2db167ad3ebe
|
||||
size 42441
|
||||
@@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Sun Jul 22 05:37:08 UTC 2018 - coolo@suse.com
|
||||
|
||||
- updated to 3.001
|
||||
see /usr/share/doc/packages/perl-Mojo-SQLite/Changes
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Jul 21 05:50:16 UTC 2017 - coolo@suse.com
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package perl-Mojo-SQLite
|
||||
#
|
||||
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
|
||||
Name: perl-Mojo-SQLite
|
||||
Version: 3.000
|
||||
Version: 3.001
|
||||
Release: 0
|
||||
%define cpan_name Mojo-SQLite
|
||||
Summary: Tiny Mojolicious Wrapper for Sqlite
|
||||
@@ -30,7 +30,7 @@ BuildArch: noarch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
BuildRequires: perl
|
||||
BuildRequires: perl-macros
|
||||
BuildRequires: perl(DBD::SQLite) >= 1.50
|
||||
BuildRequires: perl(DBD::SQLite) >= 1.54
|
||||
BuildRequires: perl(DBI) >= 1.627
|
||||
BuildRequires: perl(Module::Build::Tiny) >= 0.034
|
||||
BuildRequires: perl(Module::Metadata)
|
||||
@@ -40,7 +40,7 @@ BuildRequires: perl(Test::More) >= 0.88
|
||||
BuildRequires: perl(URI) >= 1.69
|
||||
BuildRequires: perl(URI::db) >= 0.15
|
||||
BuildRequires: perl(URI::file) >= 4.21
|
||||
Requires: perl(DBD::SQLite) >= 1.50
|
||||
Requires: perl(DBD::SQLite) >= 1.54
|
||||
Requires: perl(DBI) >= 1.627
|
||||
Requires: perl(Mojolicious) >= 7.32
|
||||
Requires: perl(SQL::Abstract) >= 1.81
|
||||
@@ -56,71 +56,6 @@ real-time web framework. Use all at http://sqlite.org/lang.html SQLite has
|
||||
to offer, generate CRUD queries from data structures, and manage your
|
||||
database schema with migrations.
|
||||
|
||||
Database and statement handles are cached automatically, so they can be
|
||||
reused transparently to increase performance. And you can handle connection
|
||||
timeouts gracefully by holding on to them only for short amounts of time.
|
||||
|
||||
use Mojolicious::Lite;
|
||||
use Mojo::SQLite;
|
||||
|
||||
helper sqlite => sub { state $sql = Mojo::SQLite->new('sqlite:test.db') };
|
||||
|
||||
get '/' => sub {
|
||||
my $c = shift;
|
||||
my $db = $c->sqlite->db;
|
||||
$c->render(json => $db->query('select datetime("now","localtime") as now')->hash);
|
||||
};
|
||||
|
||||
app->start;
|
||||
|
||||
In this example application, we create a 'sqlite' helper to store a
|
||||
Mojo::SQLite object. Our action calls that helper and uses the method
|
||||
Mojo::SQLite/"db" to dequeue a Mojo::SQLite::Database object from the
|
||||
connection pool. Then we use the method Mojo::SQLite::Database/"query" to
|
||||
execute an at http://www.postgresql.org/docs/current/static/sql.html
|
||||
statement, which returns a Mojo::SQLite::Results object. And finally we
|
||||
call the method Mojo::SQLite::Results/"hash" to retrieve the first row as a
|
||||
hash reference.
|
||||
|
||||
All I/O and queries are performed synchronously. However, the "Write-Ahead
|
||||
Log" journal is enabled for all connections, allowing multiple processes to
|
||||
read and write concurrently to the same database file (but only one can
|
||||
write at a time). You can prevent this mode from being enabled by passing
|
||||
the option 'no_wal', but note that this is incompatible with SQLite
|
||||
databases that have already had WAL mode enabled. See
|
||||
http://sqlite.org/wal.html and DBD::SQLite/"journal_mode" for more
|
||||
information.
|
||||
|
||||
# Performed concurrently
|
||||
my $pid = fork || die $!;
|
||||
say $sql->db->query('select datetime("now","localtime") as time')->hash->{time};
|
||||
exit unless $pid;
|
||||
|
||||
All cached database handles will be reset automatically if a new process
|
||||
has been forked, this allows multiple processes to share the same
|
||||
Mojo::SQLite object safely.
|
||||
|
||||
Any database errors will throw an exception as 'RaiseError' is
|
||||
automatically enabled, so use 'eval' or Try::Tiny to catch them. This makes
|
||||
transactions with Mojo::SQLite::Database/"begin" easy.
|
||||
|
||||
While passing a file path of ':memory:' (or a custom "dsn" with
|
||||
'mode=memory') will create a temporary database, in-memory databases cannot
|
||||
be shared between connections, so subsequent calls to "db" may return
|
||||
connections to completely different databases. For a temporary database
|
||||
that can be shared between connections and processes, pass a file path of
|
||||
':temp:' to store the database in a temporary directory (this is the
|
||||
default), or consider constructing a temporary directory yourself with
|
||||
File::Temp if you need to reuse the filename. A temporary directory allows
|
||||
SQLite to create at https://www.sqlite.org/tempfiles.html safely.
|
||||
|
||||
use File::Spec::Functions 'catfile';
|
||||
use File::Temp;
|
||||
use Mojo::SQLite;
|
||||
my $tempdir = File::Temp->newdir; # Deleted when object goes out of scope
|
||||
my $tempfile = catfile $tempdir, 'test.db';
|
||||
my $sql = Mojo::SQLite->new->from_filename($tempfile);
|
||||
|
||||
%prep
|
||||
%setup -q -n %{cpan_name}-%{version}
|
||||
find . -type f ! -name \*.pl -print0 | xargs -0 chmod 644
|
||||
|
||||
Reference in New Issue
Block a user