SQL Query Execution: dbclient.exe

The dbclient.exe utility serves to execute SQL queries against local or remote Microsoft SQL, MySQL and Jet databases, including Plesk database.

After executing SELECT queries, the utility returns queries results to standard output in the following format:

<field name>\t<field name>\t...\n
<field value>\t<field value>\t...\n
<field value>\t<field value>\t...\n
...

 

Location

%plesk_bin%

 

Usage

dbclient.exe --direct-sql --sql=<SQL query> [
<option 1>=<param 1>
<option 2>=<param 2>
...
<option N>=<param N>
]

 

Example

The following command run by an Administrator creates a user interface template:

>dbclient.exe --direct-sql --sql="INSERT INTO itmpl(`name`) values('custom template')"

 

Commands

Command

Parameter

Description

Example

--direct-sql

 

Performs SQL queries.

Requires the --sql option.

To rename user interface template template1 to new custom template:

>dbclient.exe --direct-sql --sql="UPDATE itmpl SET name='new custom template' WHERE name=template1"

--help

 

Displays help on the use of the utility.

To view the help info on the use of the dbclient.exe utility:

>dbclient.exe --help

Options

Option

Parameter

Description

Example

--sql

<query>

Specifies the SQL query to be executed.

Required.

To retrieve the list of domain accounts from Plesk database provided by local MySQL server under user with login admin and password setup:

>dbclient.exe --direct-sql --provider=MySQL --host=localhost --db=psa --login=admin --password=setup --port=3306 --sql="SELECT * FROM domains"

 

--provider

Jet|MySQL|MSSQL

Specifies the type of the SQL database server that will execute the query.

--host

<host_name>

Specifies the host where resides the database against which the query will be executed.

--port

<number>

Specifies the number of port on which the required database server listens to.

--db

<database_name>

Specifies the name the SQL database (or, if Jet, path to the database file) against which the query will be executed.

--login

<login_name>

Specifies login of the database user under which the query will be executed.

--password

<password>

Specifies password of the database user under which the query will be executed.

 

Note: If the utility is run with Administrator's rights, and the options --provider, --host, --port --db, --login and --password are not specified, the query will be executed against the Plesk database.
In case when the utility is run without Administrator's rights, all the options are required no matter which database is the target.