Command Line Interface

RazorSQL has a command line interface for users to call RazorSQL operations without actually launching the RazorSQL graphical program. The command line interface can be used for users who want to run scheduled programs such as nightly batch scripts.

Executing a Command

To use the RazorSQL command line interface, RazorSQL must be launched from a command prompt or terminal window or script. There are potentially slight differences depending on whether the operating system is Windows, Mac OS X, or Linux / Unix.

The format to run RazorSQL in command mode is the following:

java -jar razorsql.jar -command "parameter1" "parameter2" . . .

For example:

OS X / Linux / Unix

Change directory to the RazorSQL installation directory and execute the following:

java -jar razorsql.jar -export "Oracle Express" "select * from employee" csv "/Users/user/employee.txt" yes

Windows

Change directory to the RazorSQL installation directory and execute the following:

jre\bin\java -jar razorsql.jar -export "Oracle Express" "select * from employee" csv "C:\data\employee.txt" yes

For commands that may take a large amount of memory, the initial and max heap size settings for RazorSQL can be increased using the following syntax:

java -Xms64M -Xmx384M -jar razorsql.jar -command "parameter1" "parameter2" . . .

This command will start RazorSQL with 64MB of initial memory, with a maximum memory of 384MB.

 

Supported Commands

At this time, RazorSQL supports two commands, the -export command and the -import command. The -export command has the following parameters:

NOTE: Any parameters with spaces need to be enclosed in quotes (" ")

parameter 1 [required]: -export (the command to execute)

parameter 2 [required]: profile_name (the name of the profile to use to get the connection)
NOTE: The profile must have the save password option checked

parameter 3 [required]: query (the query to run to get the data to export)

parameter 4 [required]: export_format (csv,tsv,xls)

parameter 5 [required]: file to export data to

parameter 6 [optional]: show_columns (yes,no)

parameter 7 [optional]: convert nulls to blanks (yes,no)

 

The -import command has the following parameteres:

NOTE: Any parameters with spaces need to be enclosed in quotes (" ")

parameter 1 [required]: -import (the command to execute)

parameter 2 [required]: profile_name (the name of the profile to use to get the connection)
NOTE: The profile must have the save password option checked

parameter 3 [required]: delimited_file_location (the location of the comma, tab, or space delimited file)

parameter 4 [required]: delimiter (valid options are COMMA, SPACE, or TAB)

parameter 5 [required]: database (the database that contains the table, enter "null" if this is not applicable)

parameter 6 [required]: schema_or_owner (the schema or owner that contains the table, enter "null" if this is not applicable)

parameter 7 [required]: table (the name of the table to import the data to)