Next Previous Up Contents
Next: Crossmatching
Up: Output Modes
Previous: topcat

#### 6.4.12 `tosql`

Usage:

       omode=tosql protocol=<jdbc-protocol> host=<value> db=<db-name>
                   dbtable=<table-name> write=create|dropcreate|append
                   user=<username> password=<passwd>

Writes a new table to an SQL database. You need the appropriate JDBC drivers and `-Djdbc.drivers` set as usual (see Section 3.4).

Additional parameters for this output mode are:

`protocol = <jdbc-protocol>` (String)
  The driver-specific sub-protocol specifier for the JDBC connection. For MySQL's Connector/J driver, this is `mysql`, and for PostgreSQL's driver it is `postgresql`. For other drivers, you may have to consult the driver documentation.
`host = <value>` (String)
  The host which is acting as a database server.

  [Default: `localhost`]

`db = <db-name>` (String)
  The name of the database on the server into which the new table will be written.

  The value of this parameter forms the last part of the JDBC connection URL. That means that for some JDBC drivers, you can append parameter specifications to it to affect the way the connection is made to the database, e.g. "`db=some_db?useSSL=false`" for MySQL's Connector/J.

`dbtable = <table-name>` (String)
  The name of the table which will be written to the database.
`write = create|dropcreate|append` (WriteMode)
  Controls how the values are written to a table in the database. The options are:
  - `create`: Creates a new table before writing. It is an error if a table of the same name already exists.
  - `dropcreate`: Creates a new database table before writing. If a table of the same name already exists, it is dropped first.
  - `append`: Appends to an existing table. An error results if the named table has the wrong structure (number or types of columns) for the data being written.

  [Default: `create`]

`user = <username>` (String)
  User name for the SQL connection to the database.

  [Default: `mbt`]

`password = <passwd>` (String)
  Password for the SQL connection to the database.

Next Previous Up Contents
Next: Crossmatching
Up: Output Modes
Previous: topcat

STILTS - Starlink Tables Infrastructure Library Tool Set
Starlink User Note256
STILTS web page: http://www.starlink.ac.uk/stilts/
Author email: m.b.taylor@bristol.ac.uk
Mailing list: topcat-user@jiscmail.ac.uk