SYNOPSISodbx-sql [-?] [-b backend] [-c configfile] [-d database] [-f delimiter] [-h host] [-i] [-k keywordfile] [-p port] [-s separator] [-u username] [-w]
DESCRIPTIONodbx-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.
- -h, --help
- Print help including a short description of available options.
- -b, --backend=name
- Name of the database backend that should be used or path to the backend library of the OpenDBX driver.
- -c, --config=configfile
- 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.
- -d, --database=name
- Name of the database on the server or path to the database file in the local file system.
- -f, --delimiter=character
- Single character or string that should surround field values which are returned by SELECT-like statements and printed to stdout.
- -h, --host=name
- 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.
- -i, --interactive
- 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.
- -k keywordfile
- Location of a keyword file used for providing auto-completion of keywords.
- -p, --port=port
- 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.
- -s separator
- Single character or string that should separate field values which are returned by SELECT-like statements and printed to stdout.
- -u, --username=name
- Name of the user which is sent to the database server for authentication.
- -w, --password
- Prompt for a password at the command line.
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
EXIT STATUSodbx-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.