#odbc #command-line #command-line-interface #cli

app odbc-tools

Command line interface tools to query databases with via native ODBC drivers

5 releases (3 stable)

1.1.1 Feb 12, 2020
1.1.0 Jan 23, 2020
1.0.0 Oct 14, 2019
0.2.0 Aug 28, 2019
0.1.0 Jul 2, 2019

#1790 in Database interfaces

26 downloads per month

MIT license

15KB
230 lines

Latest Version Documentation License

Command line interface tools to query databases with via native ODBC drivers using 'odbc-iter' and 'odbc' Rust crates.

Installation

This package is published on crates.io.

cargo install odbc-tools

Usage example

odbc-query

Run query and print result set with given formatting.

In vertical format

odbc-query $CONNECTION_STRING vertical "select * from sys.tables limit 2"

Example output:

0   id            2001
0   name          schemas
0   schema_id     2000
0   query         NULL
0   type          10
0   system        true
0   commit_action 0
0   access        0
0   temporary     0

1   id            2007
1   name          types
1   schema_id     2000
1   query         NULL
1   type          10
1   system        true
1   commit_action 0
1   access        0
1   temporary     0

In JSON array format

odbc-query $CONNECTION_STRING json-array "select * from sys.tables limit 2"

Example output:

[2001,"schemas",2000,null,10,true,0,0,0]
[2007,"types",2000,null,10,true,0,0,0]

odbc-drivers

List installed ODBC drivers.

odbc-drivers

Example output:

DriverInfo { description: "Cloudera ODBC Driver for Apache Hive", attributes: {"Driver": "/opt/cloudera/hiveodbc/lib/universal/libclouderahiveodbc.dylib", "Description": "Cloudera ODBC Driver for Apache Hive"} }
DriverInfo { description: "MonetDB", attributes: {"Driver": "/usr/local/Cellar/monetdb/11.31.13/lib/libMonetODBC.so", "Description": "MonetDB Driver", "Setup": "/usr/local/Cellar/monetdb/11.31.13/lib/libMonetODBCs.so"} }
DriverInfo { description: "FreeTDS", attributes: {"Driver": "/usr/local/lib/libtdsodbc.so", "UsageCount": "2", "Description": "FreeTDS unixODBC Driver"} }
DriverInfo { description: "SQL Server", attributes: {"UsageCount": "1", "Description": "FreeTDS unixODBC Driver", "Driver": "/usr/local/lib/libtdsodbc.so"} }

odbc-script

Run SQL script from standard input.

echo "select * from sys.tables limit 2; select 1 as foo;" | odbc-script $CONNECTION_STRING

Example output:

  0 0   id            2001
  0 0   name          schemas
  0 0   schema_id     2000
  0 0   query         NULL
  0 0   type          10
  0 0   system        true
  0 0   commit_action 0
  0 0   access        0
  0 0   temporary     0

  0 1   id            2007
  0 1   name          types
  0 1   schema_id     2000
  0 1   query         NULL
  0 1   type          10
  0 1   system        true
  0 1   commit_action 0
  0 1   access        0
  0 1   temporary     0

  1 0   foo 1

Dependencies

~14MB
~266K SLoC