## Execution

The Libgda's SQL console tool runs is a terminal emulator, and can be launched using the gda-sql (or gda-sql-<version> for a specific version):

`gda-sql` [--help] [-l] [-L] [-C `command`] [-f `commands file`] [-o `output file`] [-p] [-s`port to use to run embedded HTTP server`] [-t`authentication token required to authenticate clients when running the embedded HTTP server`] [`connection specification`...]

The options are the following ones:

- the `--help` option gives a short help summary

- the `-l` and `-L` options respectively output a list of the defined data sources (DSN) and of the installed database adaptaters (database providers):

      [prompt]> gda-sql -l
      List of defined data sources
      DSN       | Provider | Description                          | Connection string     | Username | Global
      ----------+----------+--------------------------------------+-----------------------+----------+-------
      SalesTest | SQLite   | Test database for a sales department | DB_NAME=sales_test.db |          | FALSE
      (1 row)

      [prompt]> gda-sql -L
                                                              List of installed providers
      Provider    | Description                         | DSN parameters     | Authentication | File

      ------------+-------------------------------------+--------------------+----------------+----------------------
      -------------------------------------
      PostgreSQL  | Provider for PostgreSQL databases   | DB_NAME,           | USERNAME,      | [...]libgda-postgres.so
                                                          SEARCHPATH,          PASSWORD
                                                          HOST,
                                                          PORT,
                                                          OPTIONS,
                                                          USE_SSL
      MSAccess    | Provider for Microsoft Access files | DB_NAME,           |                | [...]libgda-mdb.so
                                                          DB_DIR
      [...]

- the `-C` and `-f` options repectively allow one to specify a single command to be run or a filename containing the commands to run before the tool exits

- the `-o` option allows to specify a file to write the output to

- the `-p` speficies that the tool should not ask for passwords when a username has been specified for a connection but no password has been specified.

- the `-s` requests the embedded HTTP server to be executed, listening on the port specified.

- the `-t` specifies a token string which clients will have to supply to authenticate themselves to the HTTP server, if running.

Connections to be opened can be specified on the command line using either:

- defined data sources (the ones listed using the `-l` option)

- connection strings which have the following format: "[<provider>://][<username>[:<password>]@]<connection_params>". Note that if provided, <username>, <password> and <provider> must be encoded as per RFC 1738

- for SQLite and MS Access files: the file name

Connections can also be opened while the tool is running using the .c internal command.

Examples:

    [prompt]> gda-sql Sales
    [prompt]> gda-sql Postgresql://username@DB_NAME=mydb SQLite://DB_NAME=fspot Sales
    [prompt]> gda-sql path/to/dbfile.db