odbc-tools

Crates.ioodbc-tools
lib.rsodbc-tools
version1.1.1
sourcesrc
created_at2019-07-02 15:11:17.103821
updated_at2020-02-12 17:22:11.582503
descriptionCommand line interface tools to query databases with via native ODBC drivers
homepage
repositoryhttps://github.com/jpastuszek/odbc-tools
max_upload_size
id145424
size52,387
Jakub Pastuszek (jpastuszek)

documentation

https://docs.rs/odbc-tools

README

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
Commit count: 40

cargo fmt