Easysoft ODBC-PostgreSQL Driver User's Guide - Configuration

Configuring the Easysoft ODBC-PostgreSQL Driver

The Easysoft ODBC-PostgreSQL Driver is installed on the computer where your applications are running. ODBC applications access ODBC drivers through the ODBC Driver Manager and a data source. The data source tells the Driver Manager which ODBC driver to load, which PostgreSQL server to connect to and how to connect to it. This chapter describes how to create data sources, use DSN-less connections and configure the Easysoft ODBC-PostgreSQL Driver.

Before setting up a data source, you must have successfully installed the Easysoft ODBC-PostgreSQL Driver.

For Easysoft ODBC-PostgreSQL Driver installation instructions, see Installation.

Chapter Guide

Configuring the Easysoft ODBC-PostgreSQL Driver

This section describes how to configure the Easysoft ODBC-PostgreSQL Driver to connect to a PostgreSQL database by using a data source or a DSN-less connection string. The section assumes you are, or are able to consult with, a database administrator.

Refer to the section relevant to your platform to continue:

Setting Up Data Sources on Unix

There are two ways to set up a data source to your PostgreSQL data:

¯ OR ¯

By default, the Easysoft ODBC-PostgreSQL Driver installation creates a SYSTEM data source named [POSTGRESQL_SAMPLE]. If you are using the unixODBC included in the Easysoft ODBC-PostgreSQL Driver distribution, the SYSTEM odbc.ini file is in /etc.

If you built unixODBC yourself, or installed it from some other source, SYSTEM data sources are stored in the path specified with the configure option --sysconfdir=directory. If sysconfdir was not specified when unixODBC was configured and built, it defaults to /usr/local/etc.

If you accepted the default choices when installing the Easysoft ODBC-PostgreSQL Driver, USER data sources must be created and edited in $HOME/.odbc.ini.


Note

To display the directory where unixODBC stores SYSTEM and USER data sources, type odbcinst -j.

By default, you must be logged in as root to edit a SYSTEM data source defined in /etc/odbc.ini.


You can either edit the sample data source or create new data sources.

Each section of the odbc.ini file starts with a data source name in square brackets [ ] followed by a number of attribute=value pairs.


Note

Attribute names in odbc.ini are not case sensitive.


The Driver attribute identifies the ODBC driver in the odbcinst.ini file to use for a data source.

When the Easysoft ODBC-PostgreSQL Driver is installed into unixODBC, it places an Easysoft ODBC-PostgreSQL entry in odbcinst.ini. For Easysoft ODBC-PostgreSQL Driver data sources therefore, you need to include a Driver = Easysoft ODBC-PostgreSQL entry.

To configure a PostgreSQL data source, in your odbc.ini file, you need to specify:

For example:

 [PostgreSQL]

 Driver= Easysoft ODBC-PostgreSQL

 Server= my_postgresql_hostname

 Database = Pagila

 User = my_user

 Password = my_password

 

Environment

The Easysoft ODBC-PostgreSQL Driver must be able to find the following shared objects, which are installed during the Easysoft ODBC-PostgreSQL Driver installation:

By default, this is located in /usr/local/easysoft/unixODBC/lib.

By default, this is located in /usr/local/easysoft/lib.

By default, this is located in /usr/local/easysoft/lib.

You may need to set and export LD_LIBRARY_PATH, SHLIB_PATH or LIBPATH (depending on your operating system and run-time linker) to include the directories where libodbcinst.so, libeslicshr.so and libessupp.so are located.


Note

The shared object file extension (.so) may vary depending on the operating system (.so, .a or .sl).


Establishing a Test Connection

The isql query tool lets you test your Easysoft ODBC-PostgreSQL Driver data sources.

To test the Easysoft ODBC-PostgreSQL Driver connection

1.  Change directory into /usr/local/easysoft/unixODBC/bin.

2.  Type ./isql.sh -v data_source, where data_source is the name of the target data source.

3.  At the prompt, type an SQL query. For example:

 SQL> select * from mytable;

¯ OR ¯

 Type help to return a list of tables:

 SQL> help

 

Setting Up Data Sources on Windows

To connect an ODBC application on a Windows machine to a Salesforce database:

1.  Open ODBC Data Source Administrator:

 The ODBC Data Source Administrator dialog box is displayed:

2.  Select the User DSN tab to set up a data source that only you can access.

¯ OR ¯

 Select the System DSN tab to create a data source which is available to anyone who logs on to this Windows machine.

3.  Click Add... to add a new data source.

 The Create New Data Source dialog box displays a list of drivers:

4.  Select Easysoft ODBC-PostgreSQL Driver and click Finish.

 The Easysoft ODBC-PostgreSQL Driver DSN Setup dialog box is displayed:

For details of the attributes that can be set on this dialog box, see Attribute Fields.


64-bit Windows

The Easysoft installer program installs both a 32-bit and a 64-bit version of the Easysoft ODBC-PostgreSQL Driver. If you want to use a 64-bit ODBC application, you need to use the 64-bit Easysoft ODBC-PostgreSQL Driver. If you want to use a 32-bit ODBC application, you need to use the 32-bit Easysoft ODBC-PostgreSQL Driver.

There is both a 32-bit and a 64-bit version of ODBC Administrator. The 64-bit ODBC Administrator is located in Control Panel under Administrative tools. To access the 32-bit ODBC Administrator in Windows 7 and earlier, in the Windows Run dialog box, type:

%windir%\syswow64\odbcad32.exe

On Windows 8, both the 32-bit and 64-bit ODBC Administrator are located in Control Panel under Administrative tools: ODBC Data Sources (32-bit) and ODBC Data Sources (64-bit).

Easysoft ODBC-PostgreSQL Driver data sources created in the 64-bit ODBC Administrator will specify the 64-bit version of the Easysoft ODBC-PostgreSQL Driver. Easysoft ODBC-PostgreSQL Driver data sources created in the 32-bit ODBC Administrator will specify the 32-bit version of the Easysoft ODBC-PostgreSQL Driver.

If you want to create an Easysoft ODBC-PostgreSQL Driver System data source for use with a 64-bit application, use the 64-bit ODBC Administrator. If you want to create an Easysoft ODBC-PostgreSQL Driver System data source for use with a 32-bit application, use the 32-bit ODBC Administrator.

For Easysoft ODBC-PostgreSQL Driver User data sources, it does not matter which version of the ODBC Administrator that you use.


Attribute Fields

This section lists the attributes which can be set for the Easysoft ODBC-PostgreSQL Driver in a table showing:

Attributes which are text fields are displayed as value.

Attributes which are logical fields can contain either 0 (to set to off) or 1 (to set to on) and are displayed as "0|1".

If an attribute can contain one of several specific values then each possible entry is displayed and separated by a pipe symbol.

For example, in the statement:

DIALECT=1|2|3

the value entered may be "1", "2" or "3".

DSN

The name of the User or System data source to be created, as used by the application when calling the SQLConnect or SQLDriverConnect functions.

Interface Value

DSN Dialog Box (Windows)

DSN

odbc.ini file (Unix)

[value]

Connect String

DSN=value

Description

Descriptive text that may be retrieved by certain applications to describe the data source.

Interface Value

DSN Dialog Box (Windows)

Description

odbc.ini file (Unix)

Description=value

Connect String

Not Used

Database

The database to to connect to. For example, to connect to the PostgreSQL sample database set the Database attribute value to Pagila.



Interface Value

DSN Dialog Box (Windows)

Database

odbc.ini file (Unix)

Database = value

Connect String

DATABASE=value

User

The user name to use when connecting to PostgreSQL. You must specify a name of a user who has access to the target PostgreSQL server.

To specify the user name in the connection string, use UID rather than User. For more information about specifying Easysoft ODBC-PostgreSQL Driver attributes in the connection string, see DSN-less Connections.



Interface Value

DSN Dialog Box (Windows)

User

odbc.ini file (Unix)

User = value

Connect String

USER=value

Password

The password for the user name.

To specify the password in the connection string, use PWD rather than Password.



Interface Value

DSN Dialog Box (Windows)

Password

odbc.ini file (Unix)

Password = value

Connect String

PASSWORD=value

Server

The host name or IP address of the machine on which the PostgreSQL server is running.



Interface Value

DSN Dialog Box (Windows)

Server

odbc.ini file (Unix)

Server = value

Connect String

SERVER = value

Port

The TCP port that the PostgreSQL server is listening on.

If you are connecting to a default instance that is listening on port 5432, the Port setting can be omitted.



Interface Value

DSN Dialog Box (Windows)

Port

odbc.ini file (Unix)

Port = num

Connect String

PORT=num

SSL Encryption

Whether the Easysoft ODBC-PostgreSQL Driver requests an encrypted connection to PostgreSQL.



Interface Value

DSN Dialog Box (Windows)

SSL Encryption

odbc.ini file (Unix)

Encrypt = Yes | No

Connect String

ENCRYPT = Yes | No

DisguiseLong

Whether the Easysoft ODBC-PostgreSQL Driver reports long PostgreSQL columns as a varchar type. Do not include both the DisguiseLong attribute and the DisguiseWlong attribute in your data source. Use in conjunction with the LimitLong attribute if you get error "ORA-00997: illegal use of LONG datatype" when using Oracle Heterogeneous Services (DG4ODBC) with Oracle.



Interface Value

DSN Dialog Box (Windows)

Not available.

odbc.ini file (Unix)

DisguiseLong = 0 | 1

Connect String

DISGUISELONG = 0 | 1

DisguiseWlong

Whether the Easysoft ODBC-PostgreSQL Driver reports wide long PostgreSQL columns as a varchar type. Do not include both the DisguiseLong attribute and the DisguiseWlong attribute in your data source. Use in conjunction with the LimitLong attribute if you get error "ORA-00997: illegal use of LONG datatype" when using Oracle Heterogeneous Services (DG4ODBC) with Oracle.



Interface Value

DSN Dialog Box (Windows)

Not available.

odbc.ini file (Unix)

DisguiseWlong = 0 | 1

Connect String

DISGUISEWLONG = 0 | 1

LimitLong

The maximum size in bytes that the Easysoft ODBC-PostgreSQL Driver reports for long PostgreSQL columns if you include and enable either the DisguiseLong or DisguiseWlong attribute in your data source.



Interface Value

DSN Dialog Box (Windows)

Not available.

odbc.ini file (Unix)

LimitLong = num

Connect String

LIMITLONG = num

DSN-less Connections

In addition to using a data source, you can also connect to a database by using a DSN-less connection string of the form:

SQLDriverConnect(..."DRIVER={Easysoft ODBC-PostgreSQL};

Server=server;UID=user;PWD=password;

Database=database;"...)

where server is the host name or IP address of the machine on which the PostgreSQL instance is running, user and password are a valid operating system user name and password and database isthe PostgreSQL database you want to connect to. You need to use the Easysoft ODBC-PostgreSQL DRIVER keyword to identify the Easysoft ODBC-PostgreSQL Driver.

Other Easysoft ODBC-PostgreSQL Driver attribute settings, as described in Setting Up Data Sources on Unix, can be added to the connection string using the same PARAMETER=value; format. For example, the following connection string connects to a PostgreSQL server that is listening on a non-standard port.

Linux example:

"DRIVER={Easysoft ODBC-PostgreSQL};Server=myhost;UID=myuser;PWD=mypassword;Database=Pagila;Port=5433"

Windows example:

"DRIVER={Easysoft PostgreSQL ODBC Driver};Server=myhost;UID=myuser;PWD=mypassword;Database=Pagila;Port=5433"