gsqlcmd Configuration File

gsqlcmd Configuration File

You can specify application settings, data providers, connections, and logging options in the gsqlcmd.exe.config and gsqlcmd32.exe.config configuration files.

Here’s a sample configuration file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <!--<add key="AppCulture" value="en-US"/>-->
    <add key="ConnectionTimeout" value="-1"/>
    <add key="CommandTimeout" value="300"/>
    <add key="SingleTags" value="meta,link,base,br,hr,img,input,wbr,col"/>
    <add key="AutoCorrectedTags" value="li,p,a"/>
    <add key="NewLineTags" value="p,div,h1,h2,h3,h4,h5,h6,hr,table,tr,th,td,ol,ul,li,form,head,meta,title,body,/body,/html"/>
    <add key="CutTags" value="script,noscript,style,link,meta,iframe"/>
    <add key="CutAttributes" value="style,onload,onmouseover,onmousedown,onmouseout,onchange,onclick,bgcolor"/>
    <add key="CutIDs" value=""/>
    <add key="CutComments" value="0"/>
    <!--<add key="CutScripts" value="0"/>-->
    <!--<add key="CutStyles" value="0"/>-->
    <!--<add key="Accept" value="application/json"/>-->
    <!--<add key="UserAgent" value="gsqlcmd 6.0"/>-->
  </appSettings>
  <system.data>
    <DbProviderFactories>
      ...
    </DbProviderFactories>
  </system.data>
  <connectionStrings>
    <add name="master" connectionString="Provider=MSOLEDBSQL;Data Source=.\SQLEXPRESS;Initial Catalog=master;Integrated Security=SSPI" providerName="System.Data.OleDb" />
    <add name="mssql" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=Test;Password=pass;User ID=user" providerName="System.Data.SqlClient" />
    <add name="mysql" connectionString="Server=localhost;Password=pass;User ID=user;Database=Test" providerName="MySql.Data.MySqlClient" />
    <add name="ora" connectionString="Provider=OraOLEDB.Oracle;Password=pass;User ID=user;Data Source=localhost/Test;PLSQLRSet=True" providerName="System.Data.OleDb" />
    <add name="pgsql" connectionString="Server=localhost;Password=pass;User ID=user;Database=rtd" providerName="Npgsql" />
    <add name="sqlite" connectionString="Data Source=test.db;Version=3;" providerName="System.Data.SQLite" />
  </connectionStrings>
  <system.diagnostics>
    <switches>
      <add name="TraceSQL" value="0"/>
    </switches>
    <trace autoflush="false" indentsize="0">
      <listeners>
        <!--<remove name="Default" />-->
        <!--<add name="Console"  type="System.Diagnostics.ConsoleTraceListener" />-->
        <!--<add name="Logfile"  type="System.Diagnostics.TextWriterTraceListener" initializeData="gsqlcmd.log" />-->
      </listeners>
    </trace>
  </system.diagnostics>
</configuration>

Configuration File Locations

gsqlcmd reads configuration files from three locations:

  • The folder containing gsqlcmd.exe
  • %LocalAppData%\Gartle\gsqlcmd
  • The current folder

The configuration file in the gsqlcmd.exe folder can include all sections. Configuration files in other folders may only contain the connectionStrings section.

connectionStrings

The connectionStrings section holds named connection strings. You can reference these names in the <connection> parameter like this:

gsqlcmd exec master "select name from sys.databases"

Use the edit-connections mode with the /local, /user, and /app options to edit connections visually using gConnectionManager.

To display connections, use the show-connections mode.

appSettings

This section defines default application settings. You can override these defaults at runtime using options with the same names, such as:

system.data

This section defines the data providers included with gsqlcmd. Typically, you won’t need to modify this section.

system.diagnostics

Use this section to enable SQL command tracing and define a log file.

To enable SQL command tracing, set the TraceSQL switch value to 1.

To specify the log file, uncomment the relevant line and edit the paths in the initializeData attribute.

This website is using cookies. By continuing to browse, you give us your consent to our use of cookies as explained in our Cookie Policy.