Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Pyodbc prevented from establishing connection when using PostgreSQL Unicode driver.

Date: Wed, 26 Sep 2012 18:41:31 -0700 (PDT)
From: eatmeimadan...@gmail.com
To: pyodbc@googlegroups.com
Message-Id: <f0309a3a-e2fb-4a0d-b5ce-e965ad1a38f8@googlegroups.com>
In-Reply-To: <27700702.742.1334869758319.JavaMail.geo-discussion-forums@vbut24>
References: <27700702.742.1334869758319.JavaMail.geo-discussion-forums@vbut24>
Subject: Re: Pyodbc prevented from establishing connection when using
 PostgreSQL Unicode driver.
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_53_21181779.1348710091196"

------=_Part_53_21181779.1348710091196
Content-Type: multipart/alternative; 
	boundary="----=_Part_54_23198083.1348710091196"

------=_Part_54_23198083.1348710091196
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

This has been a while, but thought I would chime in.  You do not need an 
ODBC setup on the local machine to connect with PYODBC and PSYCOPG2.  
PYODBC Example connecting to MSSQL:

[code]
import pyodbc
msconn_string = 'DRIVER={SQL 
Server};SERVER=krypton;DATABASE=master;UID=superman;PWD=loislane'
try:
    connect = pyodbc.connect(msconn_string)
except:
    sys.exit("Unable to connect to MSSQL database")
cursor = connect.cursor()
[/code]

PSYCOPG2 Example connecting to PostgreSQL:

[code]
import psycopg2
pconn_string = "host='gothim' dbname='batlayer' user='batman' 
password='vickyvale'"
try:
    pconn = psycopg2.connect(pconn_string)
except:
    sys.exit("Unable to connect to PostgreSQL database")
cursor = pconn.cursor()
[/code] 

I don't setup anything in ODBC and don't even have the native drivers or 
postgresql drivers installed.  

------=_Part_54_23198083.1348710091196
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

This has been a while, but thought I would chime in. &nbsp;You do not need =
an ODBC setup on the local machine to connect with PYODBC and PSYCOPG2. &nb=
sp;<div>PYODBC Example connecting to MSSQL:</div><div><br></div><div>[code]=
</div><div>import pyodbc</div><div>msconn_string =3D 'DRIVER=3D{SQL Server}=
;SERVER=3Dkrypton;DATABASE=3Dmaster;UID=3Dsuperman;PWD=3Dloislane'<br></div=
><div><div>try:</div><div>&nbsp; &nbsp; connect =3D pyodbc.connect(msconn_s=
tring)</div><div>except:</div><div>&nbsp; &nbsp; sys.exit("Unable to connec=
t to MSSQL database")<br></div><div>cursor =3D connect.cursor()<br></div></=
div><div>[/code]</div><div><br></div><div>PSYCOPG2 Example connecting to Po=
stgreSQL:</div><div><br></div><div>[code]</div><div>import psycopg2</div><d=
iv><div>pconn_string =3D "host=3D'gothim' dbname=3D'batlayer' user=3D'batma=
n' password=3D'vickyvale'"<br></div><div>try:</div><div>&nbsp; &nbsp; pconn=
 =3D psycopg2.connect(pconn_string)</div><div>except:</div><div>&nbsp; &nbs=
p; sys.exit("Unable to connect to PostgreSQL database")<br></div><div>curso=
r =3D pconn.cursor()<br></div></div><div>[/code]&nbsp;</div><div><br></div>=
<div>I don't setup anything in ODBC and don't even have the native drivers =
or postgresql drivers installed. &nbsp;</div>
------=_Part_54_23198083.1348710091196--

------=_Part_53_21181779.1348710091196--