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