PostgreJS
Code
import { Connection } from 'postgrejs';
async function selectOne() {
const connection = new Connection(process.env.DATABASE_URL);
await connection.connect();
const result = await connection.query('SELECT $1::text AS greeting', { params: ['Hello world!'] });
console.log(result);
await connection.close();
}
selectOne();
Elephantshark transcript
listening ...
connected at t0 = 2025-10-08 22:40:30 +0200
client -> script: "\x00\x00\x00\x08\x04\xd2\x16\x2f" = SSLRequest
script -> client: "S" = SSL supported
TLSv1.3/TLS_AES_128_GCM_SHA256 connection established with client
server name via SNI: localhost
client -> script: "\x00\x00\x00\x4d" = 77 bytes of startup message "\x00\x03\x00\x00" = protocol version
"user\x00" = key "frodo\x00" = value
"database\x00" = key "postgres\x00" = value
"application_name\x00" = key "\x00" = value
"client_encoding\x00" = key "UTF8\x00" = value
"\x00" = end
connecting to Postgres server: localhost
script -> server: "\x00\x00\x00\x08\x04\xd2\x16\x2f" = SSLRequest
server -> script: "S" = SSL supported
TLSv1.3/TLS_AES_256_GCM_SHA384 connection established with server
forwarding client startup message to server
script -> server: "\x00\x00\x00\x4d" = 77 bytes of startup message "\x00\x03\x00\x00" = protocol version
"user\x00" = key "frodo\x00" = value
"database\x00" = key "postgres\x00" = value
"application_name\x00" = key "\x00" = value
"client_encoding\x00" = key "UTF8\x00" = value
"\x00" = end
forwarding all later traffic
server -> client: "R" = Authentication "\x00\x00\x00\x2a" = 42 bytes "\x00\x00\x00\x0a" = AuthenticationSASL
"SCRAM-SHA-256-PLUS\x00" = SASL mechanism
"SCRAM-SHA-256\x00" = SASL mechanism
"\x00" = end
^^ 43 bytes forwarded at +0.03s, 0 bytes left in buffer
client -> server: "p" = SASLInitialResponse "\x00\x00\x00\x3b" = 59 bytes
"SCRAM-SHA-256\x00" = selected mechanism
"\x00\x00\x00\x25" = 37 bytes follow
"n,,n=frodo,r=vuTW3Bdpfu3olY4xoeutMfTA" = SCRAM client-first-message
^^ 60 bytes forwarded at +0.03s, 0 bytes left in buffer
server -> client: "R" = Authentication "\x00\x00\x00\x5c" = 92 bytes "\x00\x00\x00\x0b" = AuthenticationSASLContinue
"r=vuTW3Bdpfu3olY4xoeutMfTAQrdgtVrbxuoDdONA2EmuMusX,s=ZPXsknNfrTfGBNripnqk4A==,i=4096" = SCRAM server-first-message
^^ 93 bytes forwarded at +0.03s, 0 bytes left in buffer
client -> server: "p" = SASLResponse "\x00\x00\x00\x6c" = 108 bytes
"c=biws,r=vuTW3Bdpfu3olY4xoeutMfTAQrdgtVrbxuoDdONA2EmuMusX,p=m7Ov13GW/IaxshnQGEBZ15VfoqLtwTpkO+YhE3AQ/xs=" = SCRAM client-final-message
^^ 109 bytes forwarded at +0.04s, 0 bytes left in buffer
server -> client: "R" = Authentication "\x00\x00\x00\x36" = 54 bytes "\x00\x00\x00\x0c" = AuthenticationSASLFinal
"v=9dfOgur+T6GLFjVlQjPW6688yLZSF+x0rqP3jsJyW/s=" = SCRAM server-final-message
server -> client: "R" = Authentication "\x00\x00\x00\x08" = 8 bytes "\x00\x00\x00\x00" = AuthenticationOk
server -> client: "S" = ParameterStatus "\x00\x00\x00\x17" = 23 bytes "in_hot_standby\x00" = key "off\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x19" = 25 bytes "integer_datetimes\x00" = key "on\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x15" = 21 bytes "TimeZone\x00" = key "Etc/UTC\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x1b" = 27 bytes "IntervalStyle\x00" = key "postgres\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x20" = 32 bytes "search_path\x00" = key "\"$user\", public\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x14" = 20 bytes "is_superuser\x00" = key "on\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x16" = 22 bytes "application_name\x00" = key "\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x26" = 38 bytes "default_transaction_read_only\x00" = key "off\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x1a" = 26 bytes "scram_iterations\x00" = key "4096\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x17" = 23 bytes "DateStyle\x00" = key "ISO, MDY\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x23" = 35 bytes "standard_conforming_strings\x00" = key "on\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x20" = 32 bytes "session_authorization\x00" = key "frodo\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x19" = 25 bytes "client_encoding\x00" = key "UTF8\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x31" = 49 bytes "server_version\x00" = key "18.0 (Debian 18.0-1.pgdg13+3)\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x19" = 25 bytes "server_encoding\x00" = key "UTF8\x00" = value
server -> client: "K" = BackendKeyData "\x00\x00\x00\x0c" = 12 bytes "\x00\x00\x00\x59" = process ID "\xd7\x3f\xb9\xbf" = secret key
server -> client: "Z" = ReadyForQuery "\x00\x00\x00\x05" = 5 bytes "I" = idle
^^ 521 bytes forwarded at +0.04s, 0 bytes left in buffer
client -> server: "P" = Parse "\x00\x00\x00\x2a" = 42 bytes "S_1\x00" = destination prepared statement "SELECT $1::text AS greeting\x00" = SQL query "\x00\x01" = 1 parameter data types follow "\x00\x00\x04\x13" = parameter type OID: 1043
client -> server: "H" = Flush "\x00\x00\x00\x04" = 4 bytes
^^ 48 bytes forwarded at +0.05s, 0 bytes left in buffer
server -> client: "1" = ParseComplete "\x00\x00\x00\x04" = 4 bytes
^^ 5 bytes forwarded at +0.05s, 0 bytes left in buffer
client -> server: "S" = Sync "\x00\x00\x00\x04" = 4 bytes
^^ 5 bytes forwarded at +0.06s, 0 bytes left in buffer
server -> client: "Z" = ReadyForQuery "\x00\x00\x00\x05" = 5 bytes "I" = idle
^^ 6 bytes forwarded at +0.06s, 0 bytes left in buffer
client -> server: "B" = Bind "\x00\x00\x00\x26" = 38 bytes "P_1\x00" = destination portal "S_1\x00" = source prepared statement
"\x00\x01" = 1 parameter format codes follow "\x00\x01" = format: binary
"\x00\x01" = 1 parameter values follow "\x00\x00\x00\x0c" = 12 bytes follow "Hello world!" = parameter value
"\x00\x01" = 1 result format codes follow "\x00\x01" = format: binary
client -> server: "H" = Flush "\x00\x00\x00\x04" = 4 bytes
^^ 44 bytes forwarded at +0.06s, 0 bytes left in buffer
server -> client: "2" = BindComplete "\x00\x00\x00\x04" = 4 bytes
^^ 5 bytes forwarded at +0.06s, 0 bytes left in buffer
client -> server: "D" = Describe "\x00\x00\x00\x09" = 9 bytes "P" = portal "P_1\x00" = name of portal
client -> server: "H" = Flush "\x00\x00\x00\x04" = 4 bytes
^^ 15 bytes forwarded at +0.07s, 0 bytes left in buffer
server -> client: "T" = RowDescription "\x00\x00\x00\x21" = 33 bytes "\x00\x01" = 1 columns follow
"greeting\x00" = column name "\x00\x00\x00\x00" = table OID: 0 "\x00\x00" = table attrib no: 0
"\x00\x00\x00\x19" = type OID: 25 "\xff\xff" = type length: -1 "\xff\xff\xff\xff" = type modifier: -1 "\x00\x01" = format: binary
^^ 34 bytes forwarded at +0.07s, 0 bytes left in buffer
client -> server: "E" = Execute "\x00\x00\x00\x0c" = 12 bytes "P_1\x00" = portal name "\x00\x00\x00\x64" = max rows: 100
client -> server: "H" = Flush "\x00\x00\x00\x04" = 4 bytes
^^ 18 bytes forwarded at +0.07s, 0 bytes left in buffer
server -> client: "D" = DataRow "\x00\x00\x00\x16" = 22 bytes "\x00\x01" = 1 columns follow
"\x00\x00\x00\x0c" = 12 bytes "Hello world!" = column value
server -> client: "C" = CommandComplete "\x00\x00\x00\x0d" = 13 bytes "SELECT 1\x00" = command tag
^^ 37 bytes forwarded at +0.08s, 0 bytes left in buffer
client -> server: "C" = Close "\x00\x00\x00\x09" = 9 bytes "P" = portal "P_1\x00" = name of portal
client -> server: "S" = Sync "\x00\x00\x00\x04" = 4 bytes
^^ 15 bytes forwarded at +0.08s, 0 bytes left in buffer
server -> client: "3" = CloseComplete "\x00\x00\x00\x04" = 4 bytes
server -> client: "Z" = ReadyForQuery "\x00\x00\x00\x05" = 5 bytes "I" = idle
^^ 11 bytes forwarded at +0.08s, 0 bytes left in buffer
client -> server: "C" = Close "\x00\x00\x00\x09" = 9 bytes "S" = prepared statement "S_1\x00" = name of prepared statement
client -> server: "S" = Sync "\x00\x00\x00\x04" = 4 bytes
^^ 15 bytes forwarded at +0.09s, 0 bytes left in buffer
server -> client: "3" = CloseComplete "\x00\x00\x00\x04" = 4 bytes
server -> client: "Z" = ReadyForQuery "\x00\x00\x00\x05" = 5 bytes "I" = idle
^^ 11 bytes forwarded at +0.09s, 0 bytes left in buffer
client -> server: "X" = Terminate "\x00\x00\x00\x04" = 4 bytes
^^ 5 bytes forwarded at +0.09s, 0 bytes left in buffer
client hung up
connection end
listening ...
connection end