OCBC connection

M.-A. Lemburg mal at egenix.com
Fri Sep 28 14:52:14 EDT 2007


On 2007-09-28 20:07, Steve Holden wrote:
> kyosohma at gmail.com wrote:
>> On Sep 28, 9:57 am, "Sugrue, Sean" <Sean.Sug... at analog.com> wrote:
>>> I'm trying to make an odbc connection to postgresql which is on a server
>>> using python.
>>> Does anyone have a code snippet to make a basic connection with a select
>>> query?
>>>
>>> Sean
>> Sean,
>>
>> This appears to be what you're looking for:
>>
>> http://www.devx.com/opensource/Article/29071
>>
>> See also Python Database spec and module page:
>>
>> http://www.python.org/topics/database/
>>
> Mike:
> 
> This doesn't address the ODBC part of the inquiry. I was actually going 
> to respond saying I wasn't aware of an ODBC driver for PostgreSQL 
> (though I'd be surprised if there wasn't one).

There is one:

http://www.postgresql.org/ftp/odbc/versions/

and it works quite well with mxODBC on all supported platforms.

Here's a step-by-step guide for the Windows installation:

http://www.sparxsystems.com/EAUserGuide/setupapostgresqlodbcdriver.htm

Note that you should add these settings to your odbc.ini
section for the PostgreSQL data source in order to avoid
problems with BLOBs:

# Fetch BYTEA and TEXT as LongVarXXX column types:
ByteaAsLongVarBinary = 1
TextAsLongVarchar = 1

Alternatively, you can try the OpenLink driver:

http://uda.openlinksw.com/odbc/st/odbc-postgres-st/

If you're on Max OS, you should have a look at the ActualTech
drivers:

http://www.actualtechnologies.com/product_opensourcedatabases.php

Regards,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Sep 28 2007)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611



More information about the Python-list mailing list