Send a PostgreSQL wire protocol message
(sock, msg_type, body)
| 29 | return msg_type, body |
| 30 | |
| 31 | def send_message(sock, msg_type, body): |
| 32 | """Send a PostgreSQL wire protocol message""" |
| 33 | if msg_type: |
| 34 | msg = msg_type.encode() + struct.pack('!I', len(body) + 4) + body |
| 35 | else: |
| 36 | # Startup message has no type byte |
| 37 | msg = struct.pack('!I', len(body) + 4) + body |
| 38 | sock.send(msg) |
| 39 | |
| 40 | def main(): |
| 41 | # Start pgsqlite |