| I l@ve RuBoard |
|
ODBCOpen database connectivity (ODBC) is an API that provides a product-neutral interface between front-end applications and database servers. ODBC drivers are primarily used to connect Windows-based applications to various RDBMSs. However, ODBC drivers are available for almost all platforms, including UNIX, Mac, and others. InstallationPostgreSQL can be compiled (or installed from packages) with the necessary drivers for ODBC access. Although PostgreSQL includes some built-in ODBC drivers, other projects are more supported. One of the more popular ODBC access methods is currently the unixODBC project (see www.unixodbc.org). Installation of the ODBC drivers can be broken up into five steps:
Before the actual installation of the chosen ODBC driver can begin, an ODBC manager must previously exist on the system.All versions of Windows from Windows 95 on already include an ODBC manager. For UNIX/Linux clients, there are several choices. There is the unixODBC manager applet, and there is a free ODBC client called iODBC. (More information can be obtained from www.unixodbc.org or www.iodbc.org.) If your system was installed from source code, the option --enable-odbc could've been supplied at compile time. (See Chapter 10, "Common Administrative Tasks," for more compile-time options.) Likewise, most of the package-based installs also provide an optional package that includes the required ODBC functionality (for example, postgresql-odbc-7.1.2-4PGDG.i386.rpm). Alternatively, if the system has previously been compiled without the ODBC option, it can still be compiled by running the make install command in the appropriate directory (for example, src/interfaces/odbc). The base catalogs require some modifications to be completely ODBC compatible. The file odbc.sql is a collection of modifications that need to be made to the base catalog structure. It is designed to be executed as a script and should require no human inter-action. To automatically apply these changes, execute the following command as the PostgreSQL DBA user: >psql -d template1 -f PATH/odbc.sql Additionally, make sure you start the postmaster with the -i option (or make the appropriate change to the postgresql.conf file), which enables access from TCP/IP connections.Additionally, most systems require that the pg_hba.conf file be edited. (See Chapter 10 for more information on PostgreSQL administration.) Otherwise, the client would need to be local to connect successfully. As for installing the client machines, the easiest method is to download the Windows executable that automatically installs and configures Windows machines. This installer can be obtained from the following (check mirrors also): ftp://ftp.postgresql.org/pub/odbc/versions/full/ Additionally, the MS Installer (MSI) or plain DLL versions of the driver can be obtained from the following: ftp://ftp.postgresql.org/pub/odbc/versions/msi/ ftp://ftp.postgresql.org/pub/odbc/versions/dll/ The next step is to configure the odbc.ini file (or preferably, use the provided GUI management dialog). The odbc.ini file has three required sections:
Driver = Path (e.g., prefix/lib/libpsqlodbc.so) Database=DatabaseName Servername=localhost Port=5432
An alternative to specifying all of these options within an .ini file is to utilize the GUI configuration tool provided with the Windows driver. The options provided via this method include the following:
Maximum. Allows return of the maximum precision of the data type. Dont Know. Returns a "Dont Know" value and lets the application decide. Longest. Returns the longest string length of the column of any row.
Text as LongVarChar. Postgres TEXT type is mapped to SQLLongVarChar; otherwise, SQLVarChar. Unknowns as LongVarChar. Unknown types (arrays and so on) are mapped to SQLLongVarChar; otherwise, SQLVarChar. Bools as Char. Boolean returns are mapped to SQL_CHAR; otherwise, to SQL_BIT.
The driver also has these data source/connection options:
Show Column. Shows the OID. Fake Index. Fakes a unique index on OID.This is mainly useful for older MS Access–style applications.
|
| I l@ve RuBoard |
|