Re: Getting Started with ODBC

From: "Igor Kovalenko" <Igor(dot)Kovalenko(at)motorola(dot)com>
To: <pgsql-odbc(at)postgresql(dot)org>, "Andrew Bell" <acbell(at)iastate(dot)edu>
Subject: Re: Getting Started with ODBC
Date: 2001-11-29 21:01:04
Message-ID: 009901c17918$f6ddedc0$4f1db688@c773082g
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

----- Original Message -----
From: "Andrew Bell" <acbell(at)iastate(dot)edu>
To: <pgsql-odbc(at)postgresql(dot)org>
Sent: Thursday, November 29, 2001 1:15 PM
Subject: [ODBC] Getting Started with ODBC

> Hi,
>
> I *think* that I've mostly figured out what it takes to develop code that
> uses ODBC to communicate with PostgreSQL on a Linux system:
>
> 1) Driver manager (either iodbc or unixODBC)

You don't NEED that, although it might be useful if you plan to use GUI
config tools.

> 2) PostgreSQL ODBC driver

This driver can work standalone, without iodbc or uodbc (don't use
either --with-iodbc or --with-unixODBC, just --enable-odbc alone). Your
environment won't be quite coherent with MS Windows, but it probably will be
faster since you skip one level of indirection.

> 3) Some header files (unless you want to type prototypes all day)

Get them from unixODBC. You need sql.h, sqlext.h and odbcinst.h. Create your
own 'odbc.h' which will include those 3.

> 4) An initialization file (.odbc.ini)

Yes, but Postgres code dealing with it is broken. The file MUST be in user
home directory, which is not very useful when ODBC is needed for daemons
running as 'nobody' (which often does not have home directory). The code
will pick up odbcinst.h from default location (sysconfdir) but NOT .odbc.ini

>
> Is this correct? Is there anything else?

If you actually use unixODBC or iODBC, they have their own odbc.ini and
odbcinst.ini. They also have their own postgres ODBC driver (which is called
libodbcpsql.so, as opposed to Postgres own driver called libpsqlodbc.so).
You can (probably) mix driver manager (libodbc.so) from unixODBC with driver
(libpsqlodbc.so) from Postgres, but better make sure they read the same
odbc.ini & odbcinst.ini. The unixODBC looks for '.odbc.ini' in user home,
but for 'odbc.ini' in default directory. Not sure about iODBC.

> The FAQs don't, in my mind,
> cover this very well. Can someone tell me where to get an ODBC header
file
> that will work with gcc?

What I told you does work (with PHP ODBC API, at least). Note that other
software packages, like PHP will unlikely have suitable build to use
Postgres ODBC driver, even if you supply proper header files. For example
PHP can be built with unixODBC (implies driver manager and unixODBC driver)
or iODBC, but there's no such thing as 'Postgres ODBC' (--with-postgres is
*not* ODBC). I've forced it to use Postgres driver using --with-custom-odbc
variant, but it was me who added that option to PHP ;)

- igor

In response to

Browse pgsql-odbc by date

  From Date Subject
Next Message Ligia Pimentel 2001-11-29 23:22:22 An easy question about creating a primary key
Previous Message Jodi Kanter 2001-11-29 20:40:12 Visio connection