DOKK / manpages / debian 10 / opendbx-utils / odbx-sql.1.en
odbx-sql(1) OpenDBX odbx-sql(1)

odbx-sql - Swiss army knife for communicating with databases and interactive SQL shell


odbx-sql
[-?] [-b backend] [-c configfile] [-d database] [-f delimiter] [-h host] [-i] [-k keywordfile] [-p port] [-s separator] [-u username] [-w]

odbx-sql is a small and flexible utiltiy to communicate with the databases supported by the OpenDBX library. In batch mode, it's main purpose is automating tasks in shell scripts which require working with databases. On the other side, the interactive mode provides a convenient SQL shell for modifying database content or testing statements. The format of the output can be controlled to some extend by defining strings for separation between columns and for delimiting field values.

Print help including a short description of available options.
Name of the database backend that should be used or path to the backend library of the OpenDBX driver.
Configuration file with parameters required for connecting to the database. The file can include values for the backend that should be used, the host name or ip address (and maybe the port if required), the database name and the user and password. These values should be placed into the configuration file to be able to access them from non-interactive program execution savely without revealing the password anywhere. A full example of such a configuration file can be found in the example section of this manual.
Name of the database on the server or path to the database file in the local file system.
Single character or string that should surround field values which are returned by SELECT-like statements and printed to stdout.
Host name, IP address or path to the database file. It can also be the path to a named pipe in order to communicate to the database server only locally.
Run in interactive mode and provide a convenient SQL shell contrary to batch mode which is waiting for input from stdin and printing results to stdout.
Location of a keyword file used for providing auto-completion of keywords.
TCP/IP port name or number the database server is listening to. If this parameter isn't added at the command line, most database client libraries use the default value. Many but not all database server can resolve the port number from its name and for a maximum of portability the parameter value should be the port number.
Single character or string that should separate field values which are returned by SELECT-like statements and printed to stdout.
Name of the user which is sent to the database server for authentication.
Prompt for a password at the command line.

Configuration file


backend = mysql
host = localhost
port = 3306
database = test
username = myuser
password = secret

Starting in interactive mode

odbx-sql -c mysql.conf -i

Executing commands in batch mode

cat stmt.sql | odbx-sql -c mysql.conf

odbx-sql returns 1 if an error occured and 0 if all commands succeeded or only warnings are reported. If warnings occur, they are written to stderr.

28 January 2019