Mercurial > hg > monetdb-perl
comparison MonetDB-CLI/MonetDB/CLI.pm @ 0:cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
author | Sjoerd Mullender <sjoerd@acm.org> |
---|---|
date | Mon, 19 Sep 2016 15:15:52 +0200 (2016-09-19) |
parents | |
children | f899cb48b4cc |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:cedccb7e0143 |
---|---|
1 package MonetDB::CLI; | |
2 | |
3 our $VERSION = '0.03'; | |
4 | |
5 our @Modules = split /;/, $ENV{PERL_MONETDB_CLI_MODULES} | |
6 || 'MonetDB::CLI::MapiPP'; | |
7 | |
8 sub connect | |
9 { | |
10 my $class = shift; | |
11 | |
12 eval "require( $_ )" and return $_->connect( @_ ) for @Modules; | |
13 | |
14 chomp $@; die "No MonetDB::CLI implementation found: $@"; | |
15 } | |
16 | |
17 __PACKAGE__; | |
18 | |
19 =head1 NAME | |
20 | |
21 MonetDB::CLI - MonetDB Call Level Interface | |
22 | |
23 =head1 SYNOPSIS | |
24 | |
25 use MonetDB::CLI(); | |
26 | |
27 my $cxn = MonetDB::CLI->connect( $host, $port, $user, $pass, $lang, $db ); | |
28 | |
29 my $req = $cxn->query('select * from env() env'); | |
30 while ( my $cnt = $req->fetch ) { | |
31 print $req->field( $_ ) for 0 .. $cnt-1; | |
32 } | |
33 | |
34 =head1 DESCRIPTION | |
35 | |
36 MonetDB::CLI is a call level interface for MonetDB, somewhat similar | |
37 to SQL/CLI, ODBC, JDBC or DBI. | |
38 | |
39 B<Note:> In its current incarnation, this interface resembles the MonetDB | |
40 Application Programming Interface. | |
41 In the future, MAPI will be replaced by the MonetDB/Five Communication Layer | |
42 (MCL). | |
43 It is not guaranteed that this call level interface stays the same! | |
44 | |
45 =head2 The C<connect()> method | |
46 | |
47 my $cxn = MonetDB::CLI->connect( $host, $port, $user, $pass, $lang, $db ); | |
48 | |
49 This method tries to load an implementation module from C<@Modules> and | |
50 delegates to the C<connect()> method of the first successful loaded module. | |
51 Otherwise, an exception is raised. | |
52 | |
53 The default list of implementation modules can be changed with the | |
54 C<PERL_MONETDB_CLI_MODULES> environment variable. | |
55 A semicolon-separated list of module names is expected. | |
56 | |
57 =head2 Connection object methods | |
58 | |
59 It's up to the implementation modules to provide the methods for the | |
60 connection object: | |
61 | |
62 my $req = $cxn->query( $statement ); # request object | |
63 | |
64 =head2 Request object methods | |
65 | |
66 It's up to the implementation modules to provide the methods for the | |
67 request object: | |
68 | |
69 print $req->querytype; | |
70 print $req->id; | |
71 print $req->rows_affected; | |
72 print $req->columncount; | |
73 | |
74 for ( 0 .. $req->columncount - 1 ) { | |
75 print $req->name ( $_ ); | |
76 print $req->type ( $_ ); | |
77 print $req->length( $_ ); | |
78 } | |
79 while ( my $cnt = $req->fetch ) { | |
80 print $req->field( $_ ) for 0 .. $cnt-1; | |
81 } | |
82 | |
83 =head1 AUTHORS | |
84 | |
85 Steffen Goeldner E<lt>sgoeldner@cpan.orgE<gt>. | |
86 | |
87 =head1 COPYRIGHT AND LICENCE | |
88 | |
89 This Source Code Form is subject to the terms of the Mozilla Public | |
90 License, v. 2.0. If a copy of the MPL was not distributed with this | |
91 file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
92 | |
93 Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V. | |
94 | |
95 | |
96 =head1 SEE ALSO | |
97 | |
98 =head2 MonetDB | |
99 | |
100 Homepage : http://www.monetdb.org/ | |
101 | |
102 =head2 Perl modules | |
103 | |
104 L<MonetDB::CLI::MapiLib>, L<MonetDB::CLI::MapiXS>, L<MonetDB::CLI::MapiPP> | |
105 | |
106 =cut |