view mclient.pl @ 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
line wrap: on
line source
#!/usr/bin/env perl

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0.  If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.

use Mapi;

my $db = shift || '';
my $port = shift || 50000;

my ($monet, $line);
$monet = new Mapi('localhost', $port, 'monetdb', 'monetdb', 'sql', $db, 0);

print "> ";
while ( !(($line=<>) =~ /\q/) ){
	my $res = 0;
	$monet->doRequest($line);
	while( ($res = $monet->getReply()) > 0 )  {
		print $monet->{row} . "\n";
	}
	if ($res < 0) {
		if ($res == -1) {
			print $monet->{errstr};
		} elsif ($res == -2) {
			print "$monet->{count} rows affected\n";
		}
	}
	print "> ";
}

$monet->disconnect();

1;