#odbc #csv #sql

app odbcsv

Query an ODBC data source and print the result as csv

51 releases

0.3.41 Sep 5, 2021
0.3.37 Aug 28, 2021
0.3.34 Jul 19, 2021
0.3.23 Mar 28, 2021
0.3.4 Nov 21, 2020

#290 in Command line utilities

Download history 10/week @ 2021-05-28 10/week @ 2021-06-04 60/week @ 2021-06-11 13/week @ 2021-06-18 9/week @ 2021-06-25 78/week @ 2021-07-16 4/week @ 2021-07-23 132/week @ 2021-07-30 28/week @ 2021-08-06 97/week @ 2021-08-13 4/week @ 2021-08-20 33/week @ 2021-08-27 53/week @ 2021-09-03 5/week @ 2021-09-10

163 downloads per month

MIT license

395KB
5.5K SLoC

ODBCSV

Query an ODBC data source and output the result as CSV or to insert from CSV into an ODBC data source.

Installation

Several installation options are available.

Download prebuilt binaries

You can download the latest binaries here from the odbc-api GitHub release: https://github.com/pacman82/odbc-api/releases/latest.

Install using cargo

cargo install odbcsv

Usage

Querying an Microsoft SQL Database and storing the result in a file

odbcsv query \
--output query.csv \
--connection-string "Driver={ODBC Driver 17 for SQL Server};Server=localhost;UID=SA;PWD=<YourStrong@Passw0rd>;" \
"SELECT title, year from Movies"

Specify user and password independently

odbcsv query \
--output query.csv \
--connection-string "Driver={ODBC Driver 17 for SQL Server};Server=localhost;" \
--user "SA" \
--password "<YourStrong@Passw0rd>" \
"SELECT title, year from Movies"

Alternatively you may also specify the ODBC_USER and ODBC_PASSWORD environment variable.

Query using data source name

odbcsv query \
--output query.csv \
--dsn my_db \
--password "<YourStrong@Passw0rd>" \
--user "SA" \
"SELECT * FROM Birthdays"

Use parameters in query

odbcsv query \
--output query.csv \
--connection-string "Driver={ODBC Driver 17 for SQL Server};Server=localhost;UID=SA;PWD=<YourStrong@Passw0rd>;" \
"SELECT * FROM Birthdays WHERE year > ? and year < ?" \
1990 2010

Insert data from CSV to database

odbcsv insert \
--input birthdays.csv \
--connection-string "Driver={ODBC Driver 17 for SQL Server};Server=localhost;UID=SA;PWD=<YourStrong@Passw0rd>;" \
Birthdays \

Use --help to see all options.

Dependencies

~4.5–6.5MB
~111K SLoC