BrookSettings.Configuration := 'library=sqldb;driver=pqconnection;host=127.0.0.1;user=USERNAME;password=PASSWORD;database=TESTDB';
BrookSettings.Configuration := 'library=sqldb;driver=postgresql;host=127.0.0.1;user=USERNAME;password=PASSWORD;database=TESTDB';
procedure TMyAction.Get;var db: TBrookDatabase; q: TBrookQuery; t: TBrookTable;begin BrookSettings.Configuration := 'library=sqldb;driver=postgresql;host=SERVER;user=USER;password=PASS;database=db'; try db := TBrookDatabase.Create; //q := TBrookQuery.Create(db); t := TBrookTable.Create(db, 'gateway'); try WriteLn(t.AsJSON); //q.SQL.Text := 'SELECT id,name,description from gateway'; //q.Open; //WriteLn(q.AsJSON); except on E:Exception do Write('ERROR:' + E.Message); end; finally FreeAndNil(db); FreeAndnil(q); FreeAndNil(t); end;
unit brokers007;{$mode objfpc}{$H+}interfaceuses BrookFCLCGIBroker, BrookUtils, BrookSQLdbBroker, PQConnection;implementationinitialization BrookSettings.Charset := 'library=sqldb;driver=postgresql;host=127.0.0.1;user=USERNAME;password=PASSWORD;database=TESTDB'; BrookSettings.Page404 := '404.html'; BrookSettings.Page500 := '500.html';end.
unit umain007;{$mode objfpc}{$H+}interfaceuses BrookDBAction, fpJSON;type TMyAction = class(TBrookDBAction) public procedure Get; override; end;implementation{ TMyAction }procedure TMyAction.Get;begin Write(Table.Open.AsJSON);end;initialization TMyAction.Register('gateway','*');end.