This repository has been archived by the owner on Feb 5, 2019. It is now read-only.
/
README
38 lines (29 loc) · 1.45 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Esquel -- An Object-Oriented SQL Library for Perl 6
-------
NOTE: This is a work in progress, and doesn't currently work at all.
When it's done, I'll be moving onto Oharem, which is referred to
a few times in here, but hasn't even been started yet.
Oh, and until Rakudo "nom" is fixed, and MiniDBI is ported to it,
the Esquel::DBI library will only work on the "ng" branch of Rakudo.
A simple way to generate SQL statements using native Perl 6 calls.
Inspired by SQL::Abstract from Perl 5.
For example (using the MiniDBI interface):
my $sql = Esquel.new;
my ($stmt, @bind) = $sql.bind.from($table).where(:$id).select('name', 'job');
## SELECT name, job FROM $table WHERE id = $id;
my $sth = $dbh.prepare($stmt);
$sth.execute(|@bind);
my $result = $sth.fetchrow_hashref;
say "{$result<name>} is a {$result<job>}";
For an even simpler interface (but assuming a DBI-compatible library)
you can use the Esquel::DBI wrapper, which turns the above into:
## Pass it the DBH object returned from a connect() call.
my $db = Esquel::DBI.new($dbh);
## This assumes 'bind' by default, to override, use 'nobind'.
my $result = $db.where(:$id).select('name', 'job').row;
say "{$result<name>} is a {$result<job>}";
TODO: After getting Esquel::DBI up and running, I intend to use it as the
foundation for a new library called Oharem. For details on that, see
the doc/oharem.txt file.
Author: Timothy Totten
License: Artistic License 2.0