This is what I think I understand.
1. Send the startup message as such. a. length of message. b. protocol major (3) c. protocol minor (0) (don't know what this is). d. message e. send 0 (Don't know why?)
O.K. Here I show my ignorance.
#!/usr/bin/python
import socket
# Connection string
cnstring = 'user=randall, database=dws, client_encoding=UNICODE, DateStyle=ISO' # This just wrapped in my email.
msg_len = str(len(cnstring))
protocol_major = '3'
protocol_minor = '0'
pgsocket = socket.socket() pgsocket.connect(('localhost', 5432)) pgsocket.send(msg_len) pgsocket.send(protocol_major) pgsocket.send(protocol_minor) pgsocket.send(cnstring) pgsocket.send('0') pgsocket.close()
When I run this, this is what shows up in the logs.
2005-05-16 10:11:34 [2638] LOG: connection received: host=127.0.0.1 port=42607
2005-05-16 10:11:34 [2638] LOG: invalid length of startup packet
Please do not recommend that I use an existing API. I'm doing this for fun and maybe to come up with a simple pure python database driver.
Randall
---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq