Executing Scripts Through the Command Line

You can automate executing the scripts using the command line.

  1. Click Start.

  2. Type ‘cmd’ in the Search programs and files text box and press the ENTER button.

  3. Type a path to the datacompare.com file located in the Devart dbForge Data Compare for PostgreSQL installation folder on your PC, and then press the SPACE key.

    C:\Program Files\Devart\Devart dbForge Data Compare for PostgreSQL\datacompare.com
    
  4. To execute the corresponding script, use the /execute command, and press the SPACE key.

    C:\Program Files\Devart\Devart dbForge Data Compare for PostgreSQL>datacompare.com /execute /?
    
  5. Specify connection details of the server where to execute the script.

    C:\Program Files\Devart\Devart dbForge Data Compare for PostgreSQL>datacompare.com /execute /connection:"Connection Lifetime=120;Host=pgSqlHost;Port=5435;Database=db1;User ID=postgres;Password=postgres;Pooling=False"
    
  6. Specify the script file.

    C:\Program Files\Devart\Devart dbForge Data Compare for PostgreSQL>datacompare.com /execute /connection:"Connection Lifetime=120;Host=pgSqlHost;Port=5435;Database=db1;User ID=postgres;Password=postgres;Pooling=False" /inputfile:"script.sql"
    
  7. Specify the password.

    C:\Program Files\Devart\Devart dbForge Data Compare for PostgreSQL>datacompare.com /execute /connection:"Connection Lifetime=120;Host=pgSqlHost;Port=5435;Database=db1;User ID=postgres;Password=postgres;Pooling=False" /inputfile:"script.sql" /Password:mypsw
    
  8. To hide the command line window, use the /quiet command. (Useful for batch files).

    C:\Program Files\Devart\Devart dbForge Data Compare for PostgreSQL>datacompare.com /execute /connection:"Connection Lifetime=120;Host=pgSqlHost;Port=5435;Database=db1;User ID=postgres;Password=postgres;Pooling=False" /inputfile:"script.sql" /Password:mypsw /quiet
    
  9. Press ENTER to run the process.

If you use the /argfile argument, all the following commands are specified inside an argfile:

/execute
/connection:"Connection Lifetime=120;Host=pgSqlHost;Port=5435;Database=db1;User ID=postgres;Password=postgres;Pooling=False"
/inputfile:"script.sql"

In this case, the command line string will be written as follows:

C:\Program Files\Devart\Devart dbForge Data Compare for PostgreSQL>datacompare.com /argfile:myarg.txt

Arguments Used in Command Line

Select corresponding command line switches to perform the required operations:

Argument Action and Usage
/connection This switch is used to specify a connection string. Command usage looks like: /connection:
/database This switch is used to specify a database to execute the script to. Databases specified in the script before will be ignored. It does not affect the objects specified with fully qualified names.
/inputfile This switch is used to specify an SQL or ZIP file with the script to execute.
/password This switch is used to specify a server password. It overrides the password specified in the connection string. Command line usage looks like: /password:
/encoding This switch is used to specify the encoding which should be applied to open and execute the script. Command line usage looks like: /encoding:<codepage/encoding name>