103 releases (6 stable)

1.0.5 Jan 29, 2024
1.0.3 Nov 25, 2023
0.4.19 Sep 1, 2023
0.4.18 Jan 13, 2023
0.3.4 Nov 21, 2020

#1102 in Database interfaces

Download history 16/week @ 2024-01-10 1/week @ 2024-01-17 49/week @ 2024-01-24 18/week @ 2024-01-31 82/week @ 2024-02-14 81/week @ 2024-02-21 37/week @ 2024-02-28 1/week @ 2024-03-06 3/week @ 2024-03-13 25/week @ 2024-03-27 122/week @ 2024-04-03

151 downloads per month

MIT license

565KB
8K 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=My@Test@Password1;" \
"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 "My@Test@Password1" \
"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 "My@Test@Password1" \
--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=My@Test@Password1;" \
"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=My@Test@Password1;" \
Birthdays \

Use --help to see all options.

Dependencies

~4–20MB
~263K SLoC