Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
introduce a SYNOPSIS
A good synopsis helps someone get started by providing a likely code template
that can be modified and built upon.

The README.md had no SYNOPSIS, and the main module file had one that targets
developers of the module, not users.
  • Loading branch information
Carl Masak committed Nov 3, 2014
1 parent 23711dd commit fb833c6
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
47 changes: 47 additions & 0 deletions README.pod
Expand Up @@ -2,6 +2,53 @@

DBIish - a simple database interface for Rakudo Perl 6

=head1 SYNOPSIS

use v6;
use DBIish;

my $dbh = DBIish.connect("SQLite", :database<example-db.sqlite3>, :RaiseError);

my $sth = $dbh.do(q:to/STATEMENT/);
DROP TABLE nom
STATEMENT

$sth = $dbh.do(q:to/STATEMENT/);
CREATE TABLE nom (
name varchar(4),
description varchar(30),
quantity int,
price numeric(5,2)
)
STATEMENT

$sth = $dbh.do(q:to/STATEMENT/);
INSERT INTO nom (name, description, quantity, price)
VALUES ( 'BUBH', 'Hot beef burrito', 1, 4.95 )
STATEMENT

$sth = $dbh.prepare(q:to/STATEMENT/);
INSERT INTO nom (name, description, quantity, price)
VALUES ( ?, ?, ?, ? )
STATEMENT

$sth.execute('TAFM', 'Mild fish taco', 1, 4.85);
$sth.execute('BEOM', 'Medium size orange juice', 2, 1.20);

$sth = $dbh.prepare(q:to/STATEMENT/);
SELECT name, description, quantity, price, quantity*price AS amount
FROM nom
STATEMENT

$sth.execute();

my $arrayref = $sth.fetchall_arrayref();
say $arrayref.elems; # 3

$sth.finish;

$dbh.disconnect;

=head1 DESCRIPTION

The DBIish project provides a simple database interface for Perl 6.
Expand Down
47 changes: 47 additions & 0 deletions lib/DBIish.pm6
Expand Up @@ -95,6 +95,53 @@ our sub SQL_INTERVAL_MINUTE_TO_SECOND { 113 }

=begin pod
=head1 SYNOPSIS
use v6;
use DBIish;
my $dbh = DBIish.connect("SQLite", :database<example-db.sqlite3>, :RaiseError);
my $sth = $dbh.do(q:to/STATEMENT/);
DROP TABLE nom
STATEMENT
$sth = $dbh.do(q:to/STATEMENT/);
CREATE TABLE nom (
name varchar(4),
description varchar(30),
quantity int,
price numeric(5,2)
)
STATEMENT
$sth = $dbh.do(q:to/STATEMENT/);
INSERT INTO nom (name, description, quantity, price)
VALUES ( 'BUBH', 'Hot beef burrito', 1, 4.95 )
STATEMENT
$sth = $dbh.prepare(q:to/STATEMENT/);
INSERT INTO nom (name, description, quantity, price)
VALUES ( ?, ?, ?, ? )
STATEMENT
$sth.execute('TAFM', 'Mild fish taco', 1, 4.85);
$sth.execute('BEOM', 'Medium size orange juice', 2, 1.20);
$sth = $dbh.prepare(q:to/STATEMENT/);
SELECT name, description, quantity, price, quantity*price AS amount
FROM nom
STATEMENT
$sth.execute();
my $arrayref = $sth.fetchall_arrayref();
say $arrayref.elems; # 3
$sth.finish;
$dbh.disconnect;
=head1 SYNOPSIS (old)
# the list is from Perl 5 DBI, uncommented is working here
use DBIish;
# TODO: @driver_names = DBI.available_drivers;
Expand Down

0 comments on commit fb833c6

Please sign in to comment.