| 
      
      
      From: Pinchart, L. <Pin...@PC...> - 2003-06-12 14:57:13
      
     | 
| > >>   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
 |