RE: Re: Can't connect using Win95 client

"Pinchart, Laurent" <[email protected]> Thu, 12 Jun 2003 16:53:53 +0200
Newsgroups gmane.comp.python.db.pypgsql.user
Message-ID <[email protected]>
> >>   File "C:\Python22\Lib\site-packages\pyPgSQL\PgSQL.py", 
> line 2118, in
> >> connect
> >>     return Connection(connInfo, client_encoding, unicode_results)
> >>   File "C:\Python22\Lib\site-packages\pyPgSQL\PgSQL.py", 
> line 2215, in
> >> __init__
> >>     raise DatabaseError, m
> >> libpq.DatabaseError: unknown host name: 192.168.1.160

I experienced the same problem today in Windows 2000.

----------------------------------------------------------------------------
------
$ python
Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyPgSQL import PgSQL
>>> PgSQL.connect()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "D:\Soft\Python22\lib\site-packages\pyPgSQL\PgSQL.py", line 2118, in
connect
    return Connection(connInfo, client_encoding, unicode_results)
  File "D:\Soft\Python22\lib\site-packages\pyPgSQL\PgSQL.py", line 2215, in
__init__
    raise DatabaseError, m
libpq.DatabaseError: could not create socket: WSAStartup not yet called
(0x00002
76D/10093)

>>> PgSQL.connect(host="localhost", database="Test")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "D:\Soft\Python22\lib\site-packages\pyPgSQL\PgSQL.py", line 2118, in
connect
    return Connection(connInfo, client_encoding, unicode_results)
  File "D:\Soft\Python22\lib\site-packages\pyPgSQL\PgSQL.py", line 2215, in
__init__
    raise DatabaseError, m
libpq.DatabaseError: unknown host name: localhost

>>> import socket
>>> PgSQL.connect(host="localhost", database="Test")
<pyPgSQL.PgSQL.Connection instance at 0x008359D0>
>>>
----------------------------------------------------------------------------
------

It seems that pyPgSQL forgets to initialize Winsock (WSAStartup). Or should
libpq do it ? This should be investigated.

Anyway, for a quick workaround, just import socket and it should work
properly.

Laurent Pinchart


-------------------------------------------------------
This SF.NET email is sponsored by: eBay
Great deals on office technology -- on eBay now! Click here:
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5