Thread: ODBC constructs
I was playing and used libpq successfully but not sure which route to go and whats the difference.
Also Can you please let me know any mapping document which maps ODBC constructs between sybase and postgres.
I was playing and used libpq successfully but not sure which route to go and whats the difference.
Also Can you please let me know any mapping document which maps ODBC constructs between sybase and postgres.
p.s. Am not sure if the earlier email was sent..sorry for spam in case it was.
Hello,My objective is to work with postgres from my linux box using C. Am not sure whether psqlODBC or libpq should be used.
I was playing and used libpq successfully but not sure which route to go and whats the difference.
Also Can you please let me know any mapping document which maps ODBC constructs between sybase and postgres.Also list of ODBC constructs to be used with postgres.Thanks in advance!Regards...
Sent from my iPad
Hello,My objective is to work with postgres from my linux box using C. Am not sure whether psqlODBC or libpq should be used.
I was playing and used libpq successfully but not sure which route to go and whats the difference.
Also Can you please let me know any mapping document which maps ODBC constructs between sybase and postgres.Also list of ODBC constructs to be used with postgres.Thanks in advance!Regards...
p.s. Am not sure if the earlier email was sent..sorry for spam in case it was.On Mon, May 20, 2013 at 5:37 PM, Dev Kumkar <devdas.kumkar@gmail.com> wrote:Hello,My objective is to work with postgres from my linux box using C. Am not sure whether psqlODBC or libpq should be used.
I was playing and used libpq successfully but not sure which route to go and whats the difference.
Also Can you please let me know any mapping document which maps ODBC constructs between sybase and postgres.Also list of ODBC constructs to be used with postgres.
If you wish to work in C,then,I would suggest libpq.I would wait for more replies on this,as I have little knowledgeabout psqlODBC.
Regards...
On 21.05.2013 08:11, Dev Kumkar wrote: > On Mon, May 20, 2013 at 9:12 PM, Atri Sharma<atri.jiit@gmail.com> wrote: > >> >> If you wish to work in C,then,I would suggest libpq.I would wait for more >> replies on this,as I have little knowledge >> about psqlODBC. >> > > Thanks for the comments. Yes objective is to work in C and found libpq > useful but am not sure about psqlODBC. > It would be really great to get comments from community here regarding > comparison between both of them and also performance perspective. Based on > my reading so far libpq is good from performance perspective. libpq is generally-speaking better than psqlodbc. The advantage of ODBC is that if you have a suitable driver, you can connect to other DBMS' as well, while libpq will only work with PostgreSQL. Unless you need such portability, go with libpq. - Heikki
libpq is generally-speaking better than psqlodbc. The advantage of ODBC is that if you have a suitable driver, you can connect to other DBMS' as well, while libpq will only work with PostgreSQL. Unless you need such portability, go with libpq.
Thanks everyone for sharing comments, really useful ones. Yes the requirement is not connecting to other DBMS but only Postgres and libpq is the correct way so far from comments here. Regarding libpq performance wanted to discuss about connection polling like pgpool but I think a separate post of performance will make sense.
So, coming back to the original question actually I am exploring on both fronts here - libpq and psqlODBC.
Just one thought here, there is an existing ODBC business logic code which is talking to sybase database and now same code need to be ported to talk to postgres, then in this case will the use of psqlODBC quick way? Otherwise porting of ODBC business logic to libpq constructs needs to be done.
for pooling, check out pgbouncer. IMHO its a better basic pooler than pg_pool.
Sure, looks like its more light weight. And I hope, its not related to the decision between libpq and psqlODBC. And will work with both?
thats the perfect use case for ODBC. you'll probably still need to rework some of your SQL if you did stuff thats Sybase specific, but thats a lot less hassle than rewriting all the API calls.
Yeah, hope you got my confusion and inclination now.
http://www.postgresql.org/ftp/odbc/versions/src/ has sources for windows or am I missing something here?
On Tue, May 21, 2013 at 12:16 PM, John R Pierce <pierce@hogranch.com> wrote:for pooling, check out pgbouncer. IMHO its a better basic pooler than pg_pool.
Sure, looks like its more light weight. And I hope, its not related to the decision between libpq and psqlODBC. And will work with both?thats the perfect use case for ODBC. you'll probably still need to rework some of your SQL if you did stuff thats Sybase specific, but thats a lot less hassle than rewriting all the API calls.
Yeah, hope you got my confusion and inclination now.Well to work with psqlODBC, will I need to recompile the psqlODBC binary and any additional stuff to get ODBC working?
http://www.postgresql.org/ftp/odbc/versions/src/ has sources for windows or am I missing something here for linux? If Windows, then I think its just download and run the distribution. And for linux are those the same archives listed in link?
Regards...
On 5/21/2013 3:32 PM, Dev Kumkar wrote:No, you don't need to recompile any libraries. You just use them.Well to work with psqlODBC, will I need to recompile the psqlODBC binary
and any additional stuff to get ODBC working?
http://www.postgresql.org/ftp/odbc/versions/src/ has sources for windows or am I missing something here for linux? If Windows, then I think its just download and run the distribution.
[snip]
Yeah, hope you got my confusion and inclination now.
Well to work with psqlODBC, will I need to recompile the psqlODBC binary and any additional stuff to get ODBC working?
http://www.postgresql.org/ftp/odbc/versions/src/ has sources for windows or am I missing something here?
Regards...
>>
Just install the driver and use it. You don’t have to build the driver. It is already built for you. Look here if you need Solaris or BSD:
http://www.postgresql.org/download/
Or go directly here for Mac, Windows or Linux:
http://www.enterprisedb.com/products-services-training/pgdownload#windows
and click on the link that is right for your operating system.
<<
>>Just install the driver and use it. You don’t have to build the driver. It is already built for you. Look here if you need Solaris or BSD:
http://www.postgresql.org/download/
Or go directly here for Mac, Windows or Linux:
http://www.enterprisedb.com/products-services-training/pgdownload#windows
and click on the link that is right for your operating system.
<<
Also this link says to compile if its non-windows - http://psqlodbc.projects.pgfoundry.org/faq.html#1.2 Check 1.3
Can you point me to samples out there?
Regards...
From: Dev Kumkar [mailto:devdas.kumkar@gmail.com]
Sent: Tuesday, May 21, 2013 1:59 PM
To: Dann Corbit
Cc: John R Pierce; pgsql-general@postgresql.org; pgsql-odbc@postgresql.org
Subject: Re: [ODBC] [GENERAL] ODBC constructs
[snip]
I already have installed this on Linux from above link some days back but not able to find library. Can you point me to the same?
Also this link says to compile if its non-windows - http://psqlodbc.projects.pgfoundry.org/faq.html#1.2 Check 1.3
Can you point me to samples out there?
Regards...
>>
When you install an ODBC driver, it does not install a library. It installs a DLL or shared object.
If you have already installed the driver, then set up your data source with a data source manager.
IODBC is a popular driver manager:
http://www.iodbc.org/dataspace/iodbc/wiki/iODBC/
and UNIXODBC is another popular choice for an ODBC driver manager:
You link your application against the ODBC library for your platform. Then it works with any data source you have configured using your driver manager.
Here is a little blurb about driver managers:
http://dev.mysql.com/doc/connector-odbc/en/connector-odbc-driver-manager.html
Here is an outline of using ODBC with IODBC:
http://www.iodbc.org/dataspace/iodbc/wiki/iODBC/ODBCOnUnix
Here are the UNIXODBC manuals:
http://www.unixodbc.org/doc/
<<
When you install an ODBC driver, it does not install a library. It installs a DLL or shared object.If you have already installed the driver, then set up your data source with a data source manager.
IODBC is a popular driver manager:
http://www.iodbc.org/dataspace/iodbc/wiki/iODBC/
and UNIXODBC is another popular choice for an ODBC driver manager:
You link your application against the ODBC library for your platform. Then it works with any data source you have configured using your driver manager.
Here is a little blurb about driver managers:
http://dev.mysql.com/doc/connector-odbc/en/connector-odbc-driver-manager.html
Here is an outline of using ODBC with IODBC:
http://www.iodbc.org/dataspace/iodbc/wiki/iODBC/ODBCOnUnix
Here are the UNIXODBC manuals:
From: Dev Kumkar [mailto:devdas.kumkar@gmail.com]
Sent: Tuesday, May 21, 2013 7:03 PM
To: Dann Corbit
Cc: John R Pierce; pgsql-general@postgresql.org; pgsql-odbc@postgresql.org
Subject: Re: [ODBC] [GENERAL] ODBC constructs
[snip]
The link http://www.enterprisedb.com/products-services-training/pgdownload#windows which you had earlier provided was postgres installation. It installed libpq but odbc library was not installed. I hope am looking at correct things.
>>
The ODBC library is contained in either the iodbc or unixodbc RPMs.
The correct RPM to use will depend on your operating system.
<<
The ODBC library is contained in either the iodbc or unixodbc RPMs.The correct RPM to use will depend on your operating system.
From: Dev Kumkar [mailto:devdas.kumkar@gmail.com]
Sent: Tuesday, May 21, 2013 7:13 PM
To: Dann Corbit
Cc: John R Pierce; pgsql-general@postgresql.org; pgsql-odbc@postgresql.org
Subject: Re: [ODBC] [GENERAL] ODBC constructs
On Tue, May 21, 2013 at 7:09 PM, Dann Corbit <DCorbit@connx.com> wrote:
The ODBC library is contained in either the iodbc or unixodbc RPMs.
The correct RPM to use will depend on your operating system.
Where are these located?
>>
I do not know if you have 64 bit or 32 bit Linux and if it is Redhat or Mandrake or whatever.
To be clear:
The PostgreSQL distribution allows you to download the PostgreSQL ODBC driver. The PostgreSQL ODBC driver is not a library. It is a shared object that uses a standardized API to communicate with the PostgreSQL database. This allows standards based tools to access the data by linking to a single library (the ODBC library) and then connecting to as many different database systems as you like that have well written ODBC drivers.
In order to use an ODBC driver, you do need an ODBC library. Microsoft has one that comes installed. For Posix systems, you can choose between IODBC and UNIXODBC implementations. I would probably try them both if I were you and choose the one that I like best.
Maybe this google query can help you:
https://www.google.com/search?q=%28iodbc+OR+unixodbc%29+postgresql+tutorial&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:unofficial&client=firefox-nightly#client=firefox-nightly&hs=6pK&rls=org.mozilla:en-US%3Aunofficial&sclient=psy-ab&q=%28iodbc+OR+unixodbc%29+postgresql+tutorial&oq=%28iodbc+OR+unixodbc%29+postgresql+tutorial&gs_l=serp.12...0.0.0.39894.0.0.0.0.0.0.0.0..0.0...0.0...1c..14.psy-ab.E8PvcYa5HCc&pbx=1&bav=on.2,or.r_qf.&bvm=bv.46751780,d.cGE&fp=9deb35a4864e0689&biw=1920&bih=1027
<<
that should have come from the base repository...Currently looking for RHEL 5. Thanks! yes looked into my machine and "yum list postgres*" listed "postgresql91-odbc.x86_64"But when trying to install, then found the base ODBC library itself are missing and those needs to be configured first on test machine.
Error: Missing Dependency: libodbc.so.1()(64bit) is needed by package postgresql91-odbc-09.00.0310-1PGDG.rhel5.x86_64 (pgdg91)
Error: Missing Dependency: libodbcinst.so.1()(64bit) is needed by package postgresql91-odbc-09.00.0310-1PGDG.rhel5.x86_64 (pgdg91)
# yum provides libodbc.so.1
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
* base: centos.mirrors.hoobly.com
* extras: centos.mirror.freedomvoice.com
* updates: centos-distro.cavecreek.net
unixODBC-libs-2.2.11-10.el5.i386 : The shared libraries required by programs that use unixODBC
Repo : base
Matched from:
Other : libodbc.so.1
unixODBC-libs-2.2.11-10.el5.i386 : The shared libraries required by programs that use unixODBC
Repo : installed
Matched from:
Other : Provides-match: libodbc.so.1
(on a 32bit EL5 system)
Since ODBC driver was missing, downloaded unixODBC-2.3.0.tar.gz and configured/make this. Now "which odbc_config" works
# which odbc_config
/usr/local/bin/odbc_config
# odbc_config --libs
-L/usr/local/lib -lodbc
But still 'yum install postgresql91-odbc' is giving errors.
Error: Missing Dependency: libodbc.so.1()(64bit) is needed by package postgresql91-odbc-09.00.0310-1PGDG.rhel5.x86_64 (pgdg91)
Error: Missing Dependency: libodbcinst.so.1()(64bit) is needed by package postgresql91-odbc-09.00.0310-1PGDG.rhel5.x86_64 (pgdg91)
Downloaded psqlodbc driver from http://psqlodbc.projects.postgresql.org/ and tried configuring it. It also gave error saying 'libpq' not found. Then ran "yum -y install postgresql91-devel" and then configured with "$ ./configure --with-libpq=/usr/pgsql-9.1/bin/pg_config" this worked without 'libpq error'. But still no real success as there were many errors thrown for 'SQLExtendedFetch' and 'SQLROWSETSIZE'.
The link http://www.enterprisedb.com/products-services-training/pgdownload#windows which you had earlier provided was postgres installation. It installed libpq but odbc library was not installed. I hope am looking at correct things.
after installing postgres for windows with that installer, run the Stack Builder tool, it will install additional postgres related packages, one of which is pgsqlODBC
-- john r pierce 37N 122W somewhere on the middle of the left coast
From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Dev Kumkar
Sent: Tuesday, May 21, 2013 7:27 PM
To: John R Pierce
Cc: pgsql-general@postgresql.org; pgsql-odbc@postgresql.org
Subject: Re: [ODBC] [GENERAL] ODBC constructs
[snip]
Suggestions?
>>
https://rhn.redhat.com/errata/RHEA-2012-0222.html
<<
after installing postgres for windows with that installer, run the Stack Builder tool, it will install additional postgres related packages, one of which is pgsqlODBCOn 5/21/2013 7:02 PM, Dev Kumkar wrote:The link http://www.enterprisedb.com/products-services-training/pgdownload#windows which you had earlier provided was postgres installation. It installed libpq but odbc library was not installed. I hope am looking at correct things.
why the heck are you not installing unixODBC-libs from RPMs ?!?
yum install unixODBC64 unixODBC64-libs unixODBC64-devel
should do it, unless you're on Red Hat Enterprise without a subscription, then you can do it the hard way...mkdir unixODBCdownloads && cd unixODBCdownloadsif you get any dependency errors, fetch the required RPMs from http://mirrors.kernel.org/centos/5/os/x86_64/CentOS/ and install manually with the rpm command. don't be surprised if the dependencies have dependencies, normally yum would sort that out automatically.
wget http://mirrors.kernel.org/centos/5/os/x86_64/CentOS/unixODBC64-2.2.14-3.el5.x86_64.rpm
wget http://mirrors.kernel.org/centos/5/os/x86_64/CentOS/unixODBC64-libs-2.2.14-3.el5.x86_64.rpm
wget http://mirrors.kernel.org/centos/5/os/x86_64/CentOS/unixODBC64-devel-2.2.14-3.el5.x86_64.rpm
rpm -Uvh *.rpm
if your application is 32bit, then you'll need to install 32bit ODBC instead of the 64bit stuff above.
if you ARE on Red Hat Enterprise Linux without a RHN subscription, you really really should be on CentOS instead, its a 100% compatible distribution rebuilt from Red Hat sources with the branding and redhat network subscription stuff removed and replaced with open yum repositories.
btw, i'm offline til next week. have fun with that.
unixODBC is done with the above method.