gda-sql-3.0

The gda-sql-3.0 tool is an interactive command line tool to run SQL commands and work with dictionaries. This tool has got several options, use the --help option to list them all.

For example to list the installed providers, do:

[prompt]> gda-sql-3.0 -L
Provider    | Description                       | DSN parameters     | File                                          
------------+-----------------------------------+--------------------+-----------------------------------------------
SQLite      | Provider for SQLite databases     | DB_NAME,           | /usr/lib/libgda-3.0/providers/libgda-sqlite.so  
                                                  DB_DIR,                                                            
                                                  LOAD_GDA_FUNCTIONS                                                       
Berkeley-DB | Provider for Berkeley databases   | FILE,              | /usr/lib/libgda-3.0/providers/libgda-bdb.so 
                                                  DATABASE                                                                
[...]
	

To list the configured data sources (DSN):

[prompt]> gda-sql-3.0 -l
DSN      | Provider   | Description  | Connection string      | Username
---------+------------+--------------+------------------------+---------
Sales    | PostgreSQL | Sales        | DB_NAME=sales          |
[...]
	

To run an interractive session, just specify a DSN (using the -s DSN option) or a connection string (using the -c "connection string" and -p provider options). Alternatively, it is also possible to use the "<provider>://<connection string>" format (such as for example "Firebird://DATABASE=/path/to/dbfile.fdb")for an all-in-one connection specification (pass this string without any option specifier), or set the GDA_SQL_CNC environment variable to contain that string, and run the command without any argument.

Several connections can be opened at once (with only one "active" at any given time), use the \c and \close to manage (open, change, close) the connections; the prompt contains the name of the current connection used.

[prompt]> gda-sql-3.0 -p SQLite -c "DB_DIR=.;DB_NAME=sales_test"
Welcome to the GDA SQL console, version 3.1.2

Type: \copyright to show usage and distribution terms
      \? for help with internal commands
      \q (or CTRL-D) to quit
      or any query terminated by a semicolon

c0> select * from customers;
id | name            | default_served_by | country | city
---+-----------------+-------------------+---------+-----
 2 | Ed Lamton       |                 4 | SP      | MDR 
 3 | Lew Bonito      |                 1 | FR      | TLS 
 4 | Mark Lawrencep  |              NULL | SP      | MDR 
 9 | Greg Popoff     |                 2 | SP      | MDR 
10 | Vladimir Zirkov |                 4 | NULL    | NULL
c0> \set the_id 9
c0> select * from customers where id= ##the_id;
id | name        | default_served_by | country | city
---+-------------+-------------------+---------+-----
 9 | Greg Popoff |                 2 | SP      | MDR 
c0>