mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-12-22 20:57:53 +00:00
sql: influx support.
This commit is contained in:
parent
2ae4b179ac
commit
d4be5907b9
228
src/sql
228
src/sql
|
@ -76,6 +76,11 @@ If no commands are given SQL is read from the keyboard or STDIN.
|
|||
Example: echo 'SELECT * FROM foo;' | sql mysql:///
|
||||
|
||||
|
||||
=item B<--csv> (alpha testing)
|
||||
|
||||
CSV output.
|
||||
|
||||
|
||||
=item B<--db-size>
|
||||
|
||||
=item B<--dbsize>
|
||||
|
@ -97,30 +102,37 @@ Print a summary of the options to GNU B<sql> and exit.
|
|||
HTML output. Turn on HTML tabular output.
|
||||
|
||||
|
||||
=item B<--show-processlist>
|
||||
=item B<--json> (alpha testing)
|
||||
|
||||
=item B<--proclist>
|
||||
=item B<--pretty> (alpha testing)
|
||||
|
||||
=item B<--listproc>
|
||||
Pretty JSON output.
|
||||
|
||||
Show the list of running queries.
|
||||
|
||||
|
||||
=item B<--show-databases>
|
||||
|
||||
=item B<--showdbs>
|
||||
|
||||
=item B<--list-databases>
|
||||
|
||||
=item B<--listdbs>
|
||||
|
||||
=item B<--show-databases>
|
||||
|
||||
=item B<--showdbs>
|
||||
|
||||
List the databases (table spaces) in the database.
|
||||
|
||||
|
||||
=item B<--show-tables>
|
||||
=item B<--listproc>
|
||||
|
||||
=item B<--proclist>
|
||||
|
||||
=item B<--show-processlist>
|
||||
|
||||
Show the list of running queries.
|
||||
|
||||
|
||||
=item B<--list-tables>
|
||||
|
||||
=item B<--show-tables>
|
||||
|
||||
=item B<--table-list>
|
||||
|
||||
List the tables in the database.
|
||||
|
@ -145,6 +157,14 @@ space. Example: pass '-U' and the user name to the program:
|
|||
I<-p "-U scott"> can also be written I<-p -U -p scott>.
|
||||
|
||||
|
||||
=item B<--precision> <I<rfc3339|h|m|s|ms|u|ns>>
|
||||
|
||||
Precision of timestamps.
|
||||
|
||||
Specifiy the format of the output timestamps: rfc3339, h, m, s, ms, u
|
||||
or ns.
|
||||
|
||||
|
||||
=item B<-r>
|
||||
|
||||
Try 3 times. Short version of I<--retries 3>.
|
||||
|
@ -215,7 +235,9 @@ http://tools.ietf.org/html/rfc3986#section-2.1 (E.g. a password
|
|||
containing '/' would contain '%2F').
|
||||
|
||||
Examples:
|
||||
|
||||
mysql://scott:tiger@my.example.com/mydb
|
||||
influxdb://scott:tiger@influxdb.example.com/foo
|
||||
sql:oracle://scott:tiger@ora.example.com/xe
|
||||
postgresql://scott:tiger@pg.example.com/pgdb
|
||||
pg:///
|
||||
|
@ -227,7 +249,8 @@ Currently supported vendors: MySQL (mysql), MySQL with SSL (mysqls,
|
|||
mysqlssl), Oracle (oracle, ora), PostgreSQL (postgresql, pg, pgsql,
|
||||
postgres), PostgreSQL with SSL (postgresqlssl, pgs, pgsqlssl,
|
||||
postgresssl, pgssl, postgresqls, pgsqls, postgress), SQLite2 (sqlite,
|
||||
sqlite2), SQLite3 (sqlite3).
|
||||
sqlite2), SQLite3 (sqlite3), InfluxDB 1.x (influx, influxdb), InfluxDB
|
||||
with SSL (influxdbssl, influxdbs, influxs, influxssl)
|
||||
|
||||
Aliases must start with ':' and are read from
|
||||
/etc/sql/aliases and ~/.sql/aliases. The user's own
|
||||
|
@ -491,7 +514,8 @@ have a command history for Oracle.
|
|||
|
||||
=head1 SEE ALSO
|
||||
|
||||
B<mysql>(1), B<psql>(1), B<rlwrap>(1), B<sqlite>(1), B<sqlite3>(1), B<sqlplus>(1)
|
||||
B<mysql>(1), B<psql>(1), B<rlwrap>(1), B<sqlite>(1), B<sqlite3>(1),
|
||||
B<sqlplus>(1), B<influx>(1)
|
||||
|
||||
=cut
|
||||
|
||||
|
@ -503,10 +527,7 @@ parse_options();
|
|||
|
||||
my $pass_through_options = (defined $::opt_p) ? join(" ",@{$::opt_p}) : "";
|
||||
my $dburl_or_alias = shift;
|
||||
if (not defined $dburl_or_alias) {
|
||||
Usage("No DBURL given");
|
||||
exit -1;
|
||||
}
|
||||
if (not defined $dburl_or_alias) { Usage("No DBURL given"); exit -1; }
|
||||
my %dburl = parse_dburl(get_alias($dburl_or_alias));
|
||||
|
||||
my $interactive_command;
|
||||
|
@ -515,15 +536,23 @@ my $batch_command;
|
|||
my $database_driver = database_driver_alias($dburl{'databasedriver'});
|
||||
if($database_driver eq "mysql" or
|
||||
$database_driver eq "mysqlssl") {
|
||||
($batch_command,$interactive_command) = mysql_commands($database_driver,%dburl);
|
||||
($batch_command,$interactive_command) =
|
||||
mysql_commands($database_driver,%dburl);
|
||||
} elsif($database_driver eq "postgresql" or
|
||||
$database_driver eq "postgresqlssl") {
|
||||
($batch_command,$interactive_command) = postgresql_commands($database_driver,%dburl);
|
||||
($batch_command,$interactive_command) =
|
||||
postgresql_commands($database_driver,%dburl);
|
||||
} elsif($database_driver eq "oracle") {
|
||||
($batch_command,$interactive_command) = oracle_commands($database_driver,%dburl);
|
||||
($batch_command,$interactive_command) =
|
||||
oracle_commands($database_driver,%dburl);
|
||||
} elsif($database_driver eq "sqlite" or
|
||||
$database_driver eq "sqlite3") {
|
||||
($batch_command,$interactive_command) = sqlite_commands($database_driver,%dburl);
|
||||
($batch_command,$interactive_command) =
|
||||
sqlite_commands($database_driver,%dburl);
|
||||
} elsif($database_driver eq "influx" or
|
||||
$database_driver eq "influxssl") {
|
||||
($batch_command,$interactive_command) =
|
||||
influx_commands($database_driver,%dburl);
|
||||
}
|
||||
|
||||
my $err;
|
||||
|
@ -561,34 +590,72 @@ if($dburl{'query'}) {
|
|||
$batch_command = "(cat $queryfile;rm $queryfile; cat) | $batch_command";
|
||||
}
|
||||
|
||||
sub shell_quote($) {
|
||||
# Quote for other shells (Bourne compatibles)
|
||||
# Inputs:
|
||||
# $string = string to be quoted
|
||||
# Returns:
|
||||
# $shell_quoted = string quoted as needed by the shell
|
||||
my $s = $_[0];
|
||||
if($s =~ /[^-_.+a-z0-9\/]/i) {
|
||||
$s =~ s/'/'"'"'/g; # "-quote single quotes
|
||||
$s = "'$s'"; # '-quote entire string
|
||||
$s =~ s/^''//; # Remove unneeded '' at ends
|
||||
$s =~ s/''$//; # (faster than s/^''|''$//g)
|
||||
return $s;
|
||||
} elsif ($s eq "") {
|
||||
return "''";
|
||||
} else {
|
||||
# No quoting needed
|
||||
return $s;
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
if (is_stdin_terminal()) {
|
||||
if(@ARGV) {
|
||||
open(M,"| $batch_command") || die("mysql/psql/sqlplus not in path");
|
||||
if(@ARGV) {
|
||||
# SQL Commands given as arguments:
|
||||
# Run those commands
|
||||
$::opt_debug and print "[ | $batch_command]\n";
|
||||
$::opt_verbose and print "[ | $batch_command]\n";
|
||||
if($database_driver eq "influx" or $database_driver eq "influxssl") {
|
||||
# Influx currently cannot read commands from stdin
|
||||
for(@ARGV) {
|
||||
s/\\n/\n/g;
|
||||
s/\\x0a/\n/gi;
|
||||
$::opt_debug and print "[$batch_command -execute $_]\n";
|
||||
system("$batch_command -execute ".shell_quote($_));
|
||||
}
|
||||
} else {
|
||||
open(M,"| $batch_command") ||
|
||||
die("mysql/psql/sqlplus/influx not in path");
|
||||
for(@ARGV) {
|
||||
s/\\n/\n/g;
|
||||
s/\\x0a/\n/gi;
|
||||
print M "$_\n";
|
||||
}
|
||||
close M;
|
||||
} else {
|
||||
$::opt_debug and print "$interactive_command\n";
|
||||
$::opt_verbose and print "$interactive_command\n";
|
||||
system("$interactive_command");
|
||||
}
|
||||
} else {
|
||||
if(@ARGV) {
|
||||
open(M,"| $batch_command") || die("mysql/psql/sqlplus not in path");
|
||||
for(@ARGV) {
|
||||
s/\\n/\n/g;
|
||||
s/\\x0a/\n/gi;
|
||||
print M "$_\n";
|
||||
}
|
||||
close M;
|
||||
if (is_stdin_terminal()) {
|
||||
# Run interactively
|
||||
$::opt_debug and print "[$interactive_command]\n";
|
||||
$::opt_verbose and print "[$interactive_command]\n";
|
||||
system("$interactive_command");
|
||||
} else {
|
||||
$::opt_debug and print "$batch_command\n";
|
||||
$::opt_verbose and print "$batch_command\n";
|
||||
system("$batch_command");
|
||||
# Let the command read from stdin
|
||||
$::opt_debug and print "[$batch_command]\n";
|
||||
$::opt_verbose and print "[$batch_command]\n";
|
||||
if($database_driver eq "influx" or $database_driver eq "influxssl") {
|
||||
# Influx currently cannot read commands from stdin
|
||||
while(<STDIN>) {
|
||||
s/\\n/\n/g;
|
||||
s/\\x0a/\n/gi;
|
||||
$::opt_debug and print "[$batch_command -execute $_]\n";
|
||||
system("$batch_command -execute ".shell_quote($_));
|
||||
}
|
||||
} else{
|
||||
system("$batch_command");
|
||||
}
|
||||
}
|
||||
}
|
||||
$err = $?>>8;
|
||||
|
@ -600,7 +667,7 @@ $Global::Initfile && unlink $Global::Initfile;
|
|||
exit ($err);
|
||||
|
||||
sub parse_options {
|
||||
$Global::version = 20220622;
|
||||
$Global::version = 20220703;
|
||||
$Global::progname = 'sql';
|
||||
|
||||
# This must be done first as this may exec myself
|
||||
|
@ -617,9 +684,11 @@ sub parse_options {
|
|||
GetOptions("passthrough|p=s@" => \$::opt_p,
|
||||
"sep|s=s" => \$::opt_s,
|
||||
"html" => \$::opt_html,
|
||||
"show-processlist|proclist|listproc" => \$::opt_processlist,
|
||||
"show-tables|showtables|listtables|list-tables|tablelist|table-list"
|
||||
=> \$::opt_tablelist,
|
||||
"show-processlist|proclist|listproc|showqueries|show-queries"
|
||||
=> \$::opt_processlist,
|
||||
"show-tables|showtables|listtables|list-tables|".
|
||||
"tablelist|table-list|show-measurements|showmeasurements|".
|
||||
"list-measurements|listmeasurements" => \$::opt_tablelist,
|
||||
"dblist|".
|
||||
"listdb|listdbs|list-db|list-dbs|list-database|".
|
||||
"list-databases|listdatabases|listdatabase|showdb|".
|
||||
|
@ -627,6 +696,10 @@ sub parse_options {
|
|||
"showdatabases|showdatabase" => \$::opt_dblist,
|
||||
"db-size|dbsize" => \$::opt_dbsize,
|
||||
"table-size|tablesize" => \$::opt_tablesize,
|
||||
"json|j" => \$::opt_json,
|
||||
"pretty" => \$::opt_pretty,
|
||||
"csv" => \$::opt_csv,
|
||||
"precision=s" => \$::opt_precision,
|
||||
"noheaders|no-headers|n" => \$::opt_n,
|
||||
"r" => \$::opt_retry,
|
||||
"retries=s" => \$::opt_retries,
|
||||
|
@ -671,6 +744,12 @@ sub database_driver_alias {
|
|||
"sqlite" => "sqlite",
|
||||
"sqlite2" => "sqlite",
|
||||
"sqlite3" => "sqlite3",
|
||||
"influx" => "influx",
|
||||
"influxdb" => "influx",
|
||||
"influxssl" => "influxssl",
|
||||
"influxdbssl" => "influxssl",
|
||||
"influxs" => "influxssl",
|
||||
"influxdbs" => "influxssl",
|
||||
);
|
||||
return $database_driver_alias{$driver};
|
||||
}
|
||||
|
@ -687,9 +766,7 @@ sub mysql_commands {
|
|||
my $html = defined($::opt_html) ? "--html" : "";
|
||||
my $no_headers = defined($::opt_n) ? "--skip-column-names" : "";
|
||||
my $ssl = "";
|
||||
if ($database_driver eq "mysqlssl") {
|
||||
$ssl="--ssl";
|
||||
}
|
||||
if ($database_driver eq "mysqlssl") { $ssl="--ssl"; }
|
||||
my($credential_fh,$tmp) = tempfile(SUFFIX => ".sql");
|
||||
chmod (0600,$tmp);
|
||||
print $credential_fh ("[client]\n",
|
||||
|
@ -702,7 +779,8 @@ sub mysql_commands {
|
|||
# -C: Compression if both ends support it
|
||||
$batch_command =
|
||||
"((sleep 1; rm $tmp) & ".
|
||||
"mysql --defaults-extra-file=$tmp -C $pass_through_options $no_headers $html $ssl $host $user $port $database)";
|
||||
"mysql --defaults-extra-file=$tmp -C $pass_through_options ".
|
||||
"$no_headers $html $ssl $host $user $port $database)";
|
||||
$interactive_command = $batch_command;
|
||||
return($batch_command,$interactive_command);
|
||||
}
|
||||
|
@ -711,7 +789,8 @@ sub postgresql_commands {
|
|||
my ($database_driver,%opt) = (@_);
|
||||
find_command_in_path("psql") || die ("psql not in path");
|
||||
my $sep = ($::opt_s) ? "-A --field-separator '$::opt_s'" : "";
|
||||
my $password = defined($opt{'password'}) ? "PGPASSWORD=".$opt{'password'} : "";
|
||||
my $password = defined($opt{'password'}) ?
|
||||
"PGPASSWORD=".$opt{'password'} : "";
|
||||
my $host = defined($opt{'host'}) ? "-h ".$opt{'host'} : "";
|
||||
my $port = defined($opt{'port'}) ? "-p ".$opt{'port'} : "";
|
||||
my $user = defined($opt{'user'}) ? "-U ".$opt{'user'} : "";
|
||||
|
@ -719,11 +798,10 @@ sub postgresql_commands {
|
|||
my $html = defined($::opt_html) ? "--html" : "";
|
||||
my $no_headers = defined($::opt_n) ? "--tuples-only" : "";
|
||||
my $ssl = "";
|
||||
if ($database_driver eq "postgresqlssl") {
|
||||
$ssl="PGSSLMODE=require";
|
||||
}
|
||||
if ($database_driver eq "postgresqlssl") { $ssl="PGSSLMODE=require"; }
|
||||
$batch_command =
|
||||
"$ssl $password psql $pass_through_options $sep $no_headers $html $host $user $port $database";
|
||||
"$ssl $password psql $pass_through_options $sep $no_headers ".
|
||||
"$html $host $user $port $database";
|
||||
$interactive_command = $batch_command;
|
||||
|
||||
return($batch_command,$interactive_command);
|
||||
|
@ -735,7 +813,7 @@ sub oracle_commands {
|
|||
# sqlplus 'user/pass@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = grum)(PORT = 1521)) (CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = XE) ))'
|
||||
my $sqlplus = find_command_in_path("sqlplus") ||
|
||||
find_command_in_path("sqlplus64") or
|
||||
die ("sqlplus/sqlplus64 not in path");
|
||||
die("sqlplus/sqlplus64 not in path");
|
||||
|
||||
# Readline support: if rlwrap installed run rlwrap sqlplus
|
||||
my $rlwrap = find_command_in_path("rlwrap");
|
||||
|
@ -774,7 +852,8 @@ sub oracle_commands {
|
|||
"(CONNECT_DATA =(SERVER = DEDICATED)$service ))";
|
||||
my $ssl = "";
|
||||
# -L: Do not re-ask for password if it is wrong
|
||||
my $common_options = "-L $pass_through_options '$user$password\@$tns' \@$Global::Initfile";
|
||||
my $common_options = "-L $pass_through_options ".
|
||||
"'$user$password\@$tns' \@$Global::Initfile";
|
||||
my $batch_command = "$sqlplus -S ".$common_options;
|
||||
my $interactive_command = "$rlwrap $sqlplus ".$common_options;
|
||||
return($batch_command,$interactive_command);
|
||||
|
@ -796,11 +875,43 @@ sub sqlite_commands {
|
|||
my $no_headers = defined($::opt_n) ? "-noheader" : "-header";
|
||||
my $ssl = "";
|
||||
$batch_command =
|
||||
"$database_driver $pass_through_options $sep $no_headers $html $database";
|
||||
"$database_driver $pass_through_options $sep ".
|
||||
"$no_headers $html $database";
|
||||
$interactive_command = $batch_command;
|
||||
return($batch_command,$interactive_command);
|
||||
}
|
||||
|
||||
sub influx_commands {
|
||||
my ($database_driver,%opt) = (@_);
|
||||
my $influx = find_command_in_path("influx") ||
|
||||
die ("influx not in path");
|
||||
if(defined($::opt_s)) {
|
||||
die "Field separator not implemented for influx";
|
||||
}
|
||||
my $password =
|
||||
defined($opt{'password'}) ? "-password=".$opt{'password'} : "";
|
||||
my $host = defined($opt{'host'}) ? "-host=".$opt{'host'} : "";
|
||||
my $port = defined($opt{'port'}) ? "-port=".$opt{'port'} : "";
|
||||
my $user = defined($opt{'user'}) ? "-username=".$opt{'user'} : "";
|
||||
my $database = defined($opt{'database'}) ?
|
||||
"-database $opt{'database'}" : "-database $ENV{'USER'}";
|
||||
|
||||
my $format = defined($::opt_json) ? "-format json" :
|
||||
defined($::opt_pretty) ? "-format json -pretty" :
|
||||
defined($::opt_csv) ? "-format csv" : "";
|
||||
my $precision = defined($::opt_precision) ?
|
||||
"-precision $::opt_precision" : "";
|
||||
|
||||
my $no_headers = defined($::opt_n) ? "--skip-column-names" : "";
|
||||
my $ssl = "";
|
||||
if($database_driver eq "influxssl") { $ssl="--ssl"; }
|
||||
|
||||
$batch_command =
|
||||
"$influx $pass_through_options $no_headers $format ".
|
||||
"$precision $ssl $host $user $password $port $database";
|
||||
$interactive_command = $batch_command;
|
||||
return($batch_command,$interactive_command);
|
||||
}
|
||||
|
||||
# Return the code for 'show processlist' in the chosen database dialect
|
||||
sub processlist {
|
||||
|
@ -823,6 +934,7 @@ sub processlist {
|
|||
' SYS.V_$SQL.SQL_ID = SYS.V_$SESSION.SQL_ID(+) '.
|
||||
"AND username IS NOT NULL ".
|
||||
"ORDER BY CPU_TIME DESC;"),
|
||||
"influx" => "show queries;",
|
||||
);
|
||||
if($statement{$dbdriver}) {
|
||||
return $statement{$dbdriver};
|
||||
|
@ -839,9 +951,12 @@ sub tablelist {
|
|||
my %statement =
|
||||
("mysql" => "show tables;",
|
||||
"postgresql" => '\dt',
|
||||
"oracle" => ("SELECT object_name FROM user_objects WHERE object_type = 'TABLE';"),
|
||||
"oracle" => ("SELECT object_name ".
|
||||
"FROM user_objects ".
|
||||
"WHERE object_type = 'TABLE';"),
|
||||
"sqlite" => ".tables",
|
||||
"sqlite3" => ".tables",
|
||||
"influx" => "show measurements;",
|
||||
);
|
||||
if($statement{$dbdriver}) {
|
||||
return $statement{$dbdriver};
|
||||
|
@ -861,6 +976,7 @@ sub dblist {
|
|||
"WHERE datname NOT IN ('template0','template1','postgres') ".
|
||||
"ORDER BY datname ASC;"),
|
||||
"oracle" => ("select * from user_tablespaces;"),
|
||||
"influx" => "show databases;",
|
||||
);
|
||||
if($statement{$dbdriver}) {
|
||||
return $statement{$dbdriver};
|
||||
|
@ -1041,7 +1157,7 @@ sub parse_dburl {
|
|||
# sql:mysql://[[user][:password]@][host][:port]/[database[?sql query]]
|
||||
|
||||
if($url=~m!(?:sql:)? # You can prefix with 'sql:'
|
||||
((?:oracle|ora|mysql|pg|postgres|postgresql)(?:s|ssl|)|
|
||||
((?:oracle|ora|mysql|pg|postgres|postgresql|influx|influxdb)(?:s|ssl|)|
|
||||
(?:sqlite|sqlite2|sqlite3)):// # Databasedriver ($1)
|
||||
(?:
|
||||
([^:@/][^:@]*|) # Username ($2)
|
||||
|
|
|
@ -4,28 +4,58 @@
|
|||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
cd /tmp
|
||||
echo '### Test of sqlite'
|
||||
for CMDSQL in sqlite sqlite3 ; do
|
||||
echo "Current command: $CMDSQL"
|
||||
rm -f sqltest.$CMDSQL
|
||||
# create database & table
|
||||
sql $CMDSQL:///sqltest.$CMDSQL "CREATE TABLE foo(n INT, t TEXT);"
|
||||
sql --list-tables $CMDSQL:///sqltest.$CMDSQL
|
||||
file sqltest.$CMDSQL
|
||||
sql $CMDSQL:///sqltest.$CMDSQL "INSERT INTO foo VALUES(1,'Line 1');"
|
||||
sql $CMDSQL:///sqltest.$CMDSQL "INSERT INTO foo VALUES(2,'Line 2');"
|
||||
sql $CMDSQL:///sqltest.$CMDSQL "SELECT * FROM foo;"
|
||||
sql -n $CMDSQL:///sqltest.$CMDSQL "SELECT * FROM foo;"
|
||||
sql -s '.' $CMDSQL:///sqltest.$CMDSQL "SELECT * FROM foo;"
|
||||
sql -n -s '.' $CMDSQL:///sqltest.$CMDSQL "SELECT * FROM foo;"
|
||||
sql -s '' $CMDSQL:///sqltest.$CMDSQL "SELECT * FROM foo;"
|
||||
sql -s ' ' $CMDSQL:///sqltest.$CMDSQL "SELECT * FROM foo;"
|
||||
sql --html $CMDSQL:///sqltest.$CMDSQL "SELECT * FROM foo;"
|
||||
sql -n --html $CMDSQL:///sqltest.$CMDSQL "SELECT * FROM foo;"
|
||||
sql --dbsize $CMDSQL:///sqltest.$CMDSQL
|
||||
sql $CMDSQL:///sqltest.$CMDSQL "DROP TABLE foo;"
|
||||
sql --dbsize $CMDSQL:///sqltest.$CMDSQL
|
||||
rm -f sqltest.$CMDSQL
|
||||
done
|
||||
par_sqlite() {
|
||||
tmp=$(mktemp -d)
|
||||
cd $tmp
|
||||
echo '### Test of sqlite'
|
||||
for CMDSQL in sqlite sqlite3 ; do
|
||||
echo "Current command: $CMDSQL"
|
||||
rm -f sqltest.$CMDSQL
|
||||
# create database & table
|
||||
sql $CMDSQL:///sqltest.$CMDSQL "CREATE TABLE foo(n INT, t TEXT);"
|
||||
sql --list-tables $CMDSQL:///sqltest.$CMDSQL
|
||||
file sqltest.$CMDSQL
|
||||
sql $CMDSQL:///sqltest.$CMDSQL "INSERT INTO foo VALUES(1,'Line 1');"
|
||||
sql $CMDSQL:///sqltest.$CMDSQL "INSERT INTO foo VALUES(2,'Line 2');"
|
||||
sql $CMDSQL:///sqltest.$CMDSQL "SELECT * FROM foo;"
|
||||
sql -n $CMDSQL:///sqltest.$CMDSQL "SELECT * FROM foo;"
|
||||
sql -s '.' $CMDSQL:///sqltest.$CMDSQL "SELECT * FROM foo;"
|
||||
sql -n -s '.' $CMDSQL:///sqltest.$CMDSQL "SELECT * FROM foo;"
|
||||
sql -s '' $CMDSQL:///sqltest.$CMDSQL "SELECT * FROM foo;"
|
||||
sql -s ' ' $CMDSQL:///sqltest.$CMDSQL "SELECT * FROM foo;"
|
||||
sql --html $CMDSQL:///sqltest.$CMDSQL "SELECT * FROM foo;"
|
||||
sql -n --html $CMDSQL:///sqltest.$CMDSQL "SELECT * FROM foo;"
|
||||
sql --dbsize $CMDSQL:///sqltest.$CMDSQL
|
||||
sql $CMDSQL:///sqltest.$CMDSQL "DROP TABLE foo;"
|
||||
sql --dbsize $CMDSQL:///sqltest.$CMDSQL
|
||||
rm -f sqltest.$CMDSQL
|
||||
done
|
||||
}
|
||||
|
||||
par_influx() {
|
||||
echo '### Test of influx'
|
||||
(
|
||||
# create database & table
|
||||
sql influx:/// "CREATE DATABASE parallel;"
|
||||
sql --show-databases influx:///
|
||||
# insert
|
||||
(echo INSERT cpu,host=serverA,region=us_west value=0.64;
|
||||
echo INSERT cpu,host=serverA,region=us_west value=0.65;
|
||||
echo 'select * from cpu' ) |
|
||||
sql influx:///parallel
|
||||
sql --show-tables influx:///parallel
|
||||
sql influx:///parallel 'SELECT * FROM cpu;'
|
||||
sql influx:///parallel 'SELECT "host", "region", "value" FROM "cpu"'
|
||||
sql --pretty influx:///parallel 'SELECT * FROM cpu;'
|
||||
sql --json influx:///parallel 'SELECT * FROM cpu;'
|
||||
sql --dbsize influx:///parallel
|
||||
sql -s . influx:///parallel 'SELECT * FROM cpu;'
|
||||
sql --html influx:///parallel 'SELECT * FROM cpu;'
|
||||
sql influx:///parallel 'drop database parallel'
|
||||
) | perl -pe 's/\d/0/g'
|
||||
}
|
||||
|
||||
|
||||
export -f $(compgen -A function | grep par_)
|
||||
compgen -A function | grep par_ | sort |
|
||||
parallel -j0 --tag -k --joblog +/tmp/jl-`basename $0` '{} 2>&1'
|
||||
|
|
|
@ -1,75 +1,143 @@
|
|||
### Test of sqlite
|
||||
Current command: sqlite
|
||||
foo
|
||||
sqltest.sqlite: SQLite 2.x database
|
||||
n|t
|
||||
1|Line 1
|
||||
2|Line 2
|
||||
1|Line 1
|
||||
2|Line 2
|
||||
n.t
|
||||
1.Line 1
|
||||
2.Line 2
|
||||
1.Line 1
|
||||
2.Line 2
|
||||
nt
|
||||
1Line 1
|
||||
2Line 2
|
||||
n t
|
||||
1 Line 1
|
||||
2 Line 2
|
||||
<TR><TH>n</TH><TH>t</TH></TR>
|
||||
<TR><TD>1</TD>
|
||||
<TD>Line 1</TD>
|
||||
</TR>
|
||||
<TR><TD>2</TD>
|
||||
<TD>Line 2</TD>
|
||||
</TR>
|
||||
<TR><TD>1</TD>
|
||||
<TD>Line 1</TD>
|
||||
</TR>
|
||||
<TR><TD>2</TD>
|
||||
<TD>Line 2</TD>
|
||||
</TR>
|
||||
bytes
|
||||
3072
|
||||
bytes
|
||||
3072
|
||||
Current command: sqlite3
|
||||
foo
|
||||
sqltest.sqlite3: SQLite 3.x database, last written using SQLite version 3037002, file counter 1, database pages 2, cookie 0x1, schema 4, UTF-8, version-valid-for 1
|
||||
n|t
|
||||
1|Line 1
|
||||
2|Line 2
|
||||
1|Line 1
|
||||
2|Line 2
|
||||
n.t
|
||||
1.Line 1
|
||||
2.Line 2
|
||||
1.Line 1
|
||||
2.Line 2
|
||||
nt
|
||||
1Line 1
|
||||
2Line 2
|
||||
n t
|
||||
1 Line 1
|
||||
2 Line 2
|
||||
<TR><TH>n</TH>
|
||||
<TH>t</TH>
|
||||
</TR>
|
||||
<TR><TD>1</TD>
|
||||
<TD>Line 1</TD>
|
||||
</TR>
|
||||
<TR><TD>2</TD>
|
||||
<TD>Line 2</TD>
|
||||
</TR>
|
||||
<TR><TD>1</TD>
|
||||
<TD>Line 1</TD>
|
||||
</TR>
|
||||
<TR><TD>2</TD>
|
||||
<TD>Line 2</TD>
|
||||
</TR>
|
||||
bytes
|
||||
8192
|
||||
bytes
|
||||
8192
|
||||
par_influx ### Test of influx
|
||||
par_influx empty input
|
||||
par_influx empty input
|
||||
par_influx empty input
|
||||
par_influx dbsize is not implemented for influx
|
||||
par_influx Field separator not implemented for influx at /usr/local/bin/sql line 889.
|
||||
par_influx name: databases
|
||||
par_influx name
|
||||
par_influx ----
|
||||
par_influx _internal
|
||||
par_influx tange
|
||||
par_influx parallel
|
||||
par_influx name: cpu
|
||||
par_influx time host region value
|
||||
par_influx ---- ---- ------ -----
|
||||
par_influx 0000000000000000000 serverA us_west 0.00
|
||||
par_influx 0000000000000000000 serverA us_west 0.00
|
||||
par_influx name: measurements
|
||||
par_influx name
|
||||
par_influx ----
|
||||
par_influx cpu
|
||||
par_influx name: cpu
|
||||
par_influx time host region value
|
||||
par_influx ---- ---- ------ -----
|
||||
par_influx 0000000000000000000 serverA us_west 0.00
|
||||
par_influx 0000000000000000000 serverA us_west 0.00
|
||||
par_influx name: cpu
|
||||
par_influx time host region value
|
||||
par_influx ---- ---- ------ -----
|
||||
par_influx 0000000000000000000 serverA us_west 0.00
|
||||
par_influx 0000000000000000000 serverA us_west 0.00
|
||||
par_influx {
|
||||
par_influx "results": [
|
||||
par_influx {
|
||||
par_influx "series": [
|
||||
par_influx {
|
||||
par_influx "name": "cpu",
|
||||
par_influx "columns": [
|
||||
par_influx "time",
|
||||
par_influx "host",
|
||||
par_influx "region",
|
||||
par_influx "value"
|
||||
par_influx ],
|
||||
par_influx "values": [
|
||||
par_influx [
|
||||
par_influx 0000000000000000000,
|
||||
par_influx "serverA",
|
||||
par_influx "us_west",
|
||||
par_influx 0.00
|
||||
par_influx ],
|
||||
par_influx [
|
||||
par_influx 0000000000000000000,
|
||||
par_influx "serverA",
|
||||
par_influx "us_west",
|
||||
par_influx 0.00
|
||||
par_influx ]
|
||||
par_influx ]
|
||||
par_influx }
|
||||
par_influx ]
|
||||
par_influx }
|
||||
par_influx ]
|
||||
par_influx }
|
||||
par_influx {"results":[{"series":[{"name":"cpu","columns":["time","host","region","value"],"values":[[0000000000000000000,"serverA","us_west",0.00],[0000000000000000000,"serverA","us_west",0.00]]}]}]}
|
||||
par_influx name: cpu
|
||||
par_influx time host region value
|
||||
par_influx ---- ---- ------ -----
|
||||
par_influx 0000000000000000000 serverA us_west 0.00
|
||||
par_influx 0000000000000000000 serverA us_west 0.00
|
||||
par_sqlite ### Test of sqlite
|
||||
par_sqlite Current command: sqlite
|
||||
par_sqlite foo
|
||||
par_sqlite sqltest.sqlite: SQLite 2.x database
|
||||
par_sqlite n|t
|
||||
par_sqlite 1|Line 1
|
||||
par_sqlite 2|Line 2
|
||||
par_sqlite 1|Line 1
|
||||
par_sqlite 2|Line 2
|
||||
par_sqlite n.t
|
||||
par_sqlite 1.Line 1
|
||||
par_sqlite 2.Line 2
|
||||
par_sqlite 1.Line 1
|
||||
par_sqlite 2.Line 2
|
||||
par_sqlite nt
|
||||
par_sqlite 1Line 1
|
||||
par_sqlite 2Line 2
|
||||
par_sqlite n t
|
||||
par_sqlite 1 Line 1
|
||||
par_sqlite 2 Line 2
|
||||
par_sqlite <TR><TH>n</TH><TH>t</TH></TR>
|
||||
par_sqlite <TR><TD>1</TD>
|
||||
par_sqlite <TD>Line 1</TD>
|
||||
par_sqlite </TR>
|
||||
par_sqlite <TR><TD>2</TD>
|
||||
par_sqlite <TD>Line 2</TD>
|
||||
par_sqlite </TR>
|
||||
par_sqlite <TR><TD>1</TD>
|
||||
par_sqlite <TD>Line 1</TD>
|
||||
par_sqlite </TR>
|
||||
par_sqlite <TR><TD>2</TD>
|
||||
par_sqlite <TD>Line 2</TD>
|
||||
par_sqlite </TR>
|
||||
par_sqlite bytes
|
||||
par_sqlite 3072
|
||||
par_sqlite bytes
|
||||
par_sqlite 3072
|
||||
par_sqlite Current command: sqlite3
|
||||
par_sqlite foo
|
||||
par_sqlite sqltest.sqlite3: SQLite 3.x database, last written using SQLite version 3037002, file counter 1, database pages 2, cookie 0x1, schema 4, UTF-8, version-valid-for 1
|
||||
par_sqlite n|t
|
||||
par_sqlite 1|Line 1
|
||||
par_sqlite 2|Line 2
|
||||
par_sqlite 1|Line 1
|
||||
par_sqlite 2|Line 2
|
||||
par_sqlite n.t
|
||||
par_sqlite 1.Line 1
|
||||
par_sqlite 2.Line 2
|
||||
par_sqlite 1.Line 1
|
||||
par_sqlite 2.Line 2
|
||||
par_sqlite nt
|
||||
par_sqlite 1Line 1
|
||||
par_sqlite 2Line 2
|
||||
par_sqlite n t
|
||||
par_sqlite 1 Line 1
|
||||
par_sqlite 2 Line 2
|
||||
par_sqlite <TR><TH>n</TH>
|
||||
par_sqlite <TH>t</TH>
|
||||
par_sqlite </TR>
|
||||
par_sqlite <TR><TD>1</TD>
|
||||
par_sqlite <TD>Line 1</TD>
|
||||
par_sqlite </TR>
|
||||
par_sqlite <TR><TD>2</TD>
|
||||
par_sqlite <TD>Line 2</TD>
|
||||
par_sqlite </TR>
|
||||
par_sqlite <TR><TD>1</TD>
|
||||
par_sqlite <TD>Line 1</TD>
|
||||
par_sqlite </TR>
|
||||
par_sqlite <TR><TD>2</TD>
|
||||
par_sqlite <TD>Line 2</TD>
|
||||
par_sqlite </TR>
|
||||
par_sqlite bytes
|
||||
par_sqlite 8192
|
||||
par_sqlite bytes
|
||||
par_sqlite 8192
|
||||
|
|
Loading…
Reference in a new issue