dsnadd
Description
Dsnadd simplifies the setup of a new ODBC data source to connect to a PSQL database. It modifies the odbc.ini file by providing the appropriate properties for the new data source.
PSQL follows the UNIXODBC standard by using the odbcinst.ini file in /usr/local/psql/etc to specify a 32-bit and a 64-bit ODBC driver. DSNs that reference the “Pervasive ODBC Interface” driver description point to the odbcinst.ini information from the odbc.ini file. A single DSN can be used by both a 32-bit application and a 64-bit application. See also Notes.
Optionally, dsnadd provides options that let you create legacy-style DSNs that specify a 32-bit driver name in odbc.ini rather than pointing to odbcinst.ini. However, such DSNs are not accessible to 64-bit applications.
Synopsis
dsnadd -dsn=myDSN -db=DBname
This creates a DSN with the description “Pervasive ODBC Interface” that can be used by both a 32-bit application and a 64-bit application on the server. The DSN is not visible as an “engine DSN” in ODBC Administrator running on a Windows client.
dsnadd -dsn=myDSN -db=DBname -host=psqlhost
This creates a DSN with the description “Pervasive ODBC Interface” that can be used by both a 32-bit application and a 64- bit application on the client.
dsnadd -dsn=myDSN -sdsn=engineDSN -host=psqlhost -clntdsn
Note that the DSN is accessible only to 32-bit applications.
dsnadd -dsn=myDSN -db=DBname -engdsn
Note that the DSN is accessible only to 32-bit applications.
dsnadd -l
Where:
myDSN is a name you want to assign to the new data source.
DBname is the name of the named database on the PSQL host.
psqlhost is the name of the host where your PSQL Server is installed.
engineDSN is the name of the engine DSN on the PSQL host.
Options
 
See Automatic in ODBC Guide.
Examples
The following example creates a server-side DSN named acctingdb that connects to a local database named region1accting.
dsnadd -dsn=acctingdb -db=region1accting
The following example creates a client-side DSN named USInvoices that connects to a database named DomesticOrders on a remote server named USInventory:
dsnadd -dsn=USInvoices -db=DomesticOrders -host=USInventory
The following example creates a deprecated, legacy-style Client DSN named bkorderclnt” that references an engine DSN named backordersrv on a machine named JapanSvr2 and uses automatic encoding.
dsnadd -dsn=bkorderclnt -sdsn=backordersrv -host=JapanSvr2 -translate=auto -clntdsn
The following example creates a deprecated, legacy-style engine DSN named partsctlg that connects to a database named partscatalog.
dsnadd -dsn=partsctlg -db=partscatalog -engdsn
Notes
On Linux or OS X distributions, individual ODBC drivers are loaded through the driver manager UNIXODBC. The driver manager maintains a mapping from Data Source Names (DSNs) to the specific PSQL ODBC drivers.
The installation of PSQL Server 64-bit or Client 64-bit leaves user-defined, preexisting 32-bit DSNs as is, meaning they are not immediately accessible from a 64-bit application. For new DSNs, the installation of both products assigns a 32-bit and a 64-bit ODBC driver in odbcinst.ini. This assignment allows a single DSN to be used by both a 32-bit application and a 64- bit application.
If you want preexisting 32-bit DSNs to be accessible to both 32-bit and 64- bit applications, you must recreate them as DSNs that connect to a named database.
ODBC and Data Source Names (DSNs)
The application bitness does not have to match the bitness of the PSQL Server product. For example, the 64-bit ODBC driver or the 32-bit ODBC driver can be used to connect to either PSQL Server 64-bit or PSQL Server 32-bit.
For the PSQL Client, however, the application bitness does have to match the bitness of the PSQL Client on the client machine. That is, if you want to use a 64-bit application on the client, the PSQL 64-bit Client must be installed.
PSQL allows DSNs to specify three different ODBC driver descriptions, as explained in the following table.
Frequently Asked Questions
The following table answers some frequently asked questions (FAQs) about ODBC and DSN support for Linux or OS X.
Yes, but you must specify the -engdsn or -clntdsn option with dsnadd. DSNs created with either option support only 32-bit applications.
ODBC Header Files
The sql.h, sqltypes.h, and sqlext.h header files for ODBC contain differences for the compilation of 32-bit and 64-bit applications. Refer to the ODBC documentation on the UNIXODBC Web site for a discussion of 64-bit ODBC. For example, you may find the following information useful: http://www.unixodbc.org/doc/ODBC64.html.
See Also
btadmin, dbmaint, isql