uses
ZConnection, ZDataset;
var
Conn: TZConnection;
Query: TZQuery;
begin
Conn := TZConnection.Create(nil);
Conn.Protocol := 'postgresql';
Conn.HostName := 'localhost';
Conn.Database := 'mi_basedatos';
Conn.User := 'usuario';
Conn.Password := 'contraseña';
Conn.Connect;
Query := TZQuery.Create(nil);
Query.Connection := Conn;
Query.SQL.Text := 'SELECT * FROM tabla;';
Query.Open;
while not Query.EOF do
begin
writeln(Query.FieldByName('campo').AsString);
Query.Next;
end;
Query.Close;
Conn.Disconnect;
end.
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter