TFBAdmin

From Lazarus wiki
Jump to navigationJump to search

English (en) français (fr)

Databases portal

References:

Tutorials/practical articles:

Databases

Advantage - MySQL - MSSQL - Postgres - Interbase - Firebird - Oracle - ODBC - Paradox - SQLite - dBASE - MS Access - Zeos

TFBAdmin tfbadmin.png is a component that aids in Interbase/Firebird administration tasks. It can be found on the SQLdb tab of the Component Palette and resides in the FBAdmin unit. It provides the following functionality:

  • add, modify or delete database users
  • backup and restore databases using single or multiple (split) files
  • get general database information
  • get the database log file listing important database events and errors

There is also a Lazarus component and demo that allows use of the FPC TFBAdmin component.

Example

This shows how to create a multi file backup of a database on a Linux server; 3 backup files, size limited to 600MB; backup progress shown in a TMemo:

procedure TForm1.logadm(Sender: TObject; msg: string; IBAdminAction: string);
begin
  Memo1.Lines.add(IBAdminAction+' : '+msg);
end;

procedure TForm1.backup;
var
  Admin:TFBAdmin;
  sl:TStringList;
begin
  Admin:=TFBAdmin.Create(self);
  sl:=TStringList.create;
  try
    Admin.UseExceptions:=true;
    Admin.Host:='192.168.2.98';
    Admin.Protocol:=IBSPTCPIP;
    Admin.User:='sysdba';
    Admin.Password:='masterkey';
    Admin.Port:= 3050;                   //change if not using the default port
    Admin.Connect;
    Admin.OnOutput:=@logadm;
    sl.Add('/home/firebird/test.bak1');
    sl.Add('/home/firebird/test.bak2');
    sl.Add('/home/firebird/test.bak3');
    Admin.BackupMultiFile('/home/firebird/test.fdb',sl,600000000,[IBBkpVerbose]);
  finally
    sl.Destroy;
    Admin.Destroy; //disconnects automatically
  end;
end;

A demo program is also available in the examples directory of the fcl-db package.

The following example shows how to backup to and restore from a single file on a Windows-server:

uses 
  FBAdmin;
 
procedure TForm1.logadm(Sender: TObject; msg: string; IBAdminAction: string);
begin
  Memo1.Lines.add(IBAdminAction + ' : ' + msg);
end;
 
procedure Backup(Database, Backupfile: string);
var
  Admin: TFBAdmin;
begin
  Admin := TFBAdmin.Create(nil);
  try
    Admin.UseExceptions := True;
    Admin.Host := '192.168.1.66';
    Admin.Protocol := IBSPTCPIP;
    Admin.User := 'SYSDBA';
    Admin.Password := 'masterkey';
    Admin.Port := 3050;            //change if not using the default port
    Admin.Connect;
    Admin.OnOutput := @Form1.logadm;
    Admin.Backup(Database, Backupfile, [IBBkpVerbose]);
  finally
    Admin.Free; //disconnects automatically
  end;
end;
 
procedure Restore(Database, Backupfile: string);
var
  Admin: TFBAdmin;
begin
  Admin := TFBAdmin.Create(nil);
  try
    Admin.UseExceptions := True;
    Admin.Host := '192.168.1.66';
    Admin.Protocol := IBSPTCPIP;
    Admin.User := 'SYSDBA';
    Admin.Password := 'masterkey';
    Admin.Port := 3050;                   //change if not using the default port
    Admin.Connect;
    Admin.OnOutput := @Form1.logadm;
    Admin.Restore(Database, Backupfile, [IBResVerbose, IBResReplace]);
  finally
    Admin.Free; //disconnects automatically
  end;
end;
 
procedure TForm1.btBackupClick(Sender: TObject);
begin
  Backup('c:\data\demo.fdb', 'c:\temp\demo.fbk');
end;
 
procedure TForm1.btRestoreClick(Sender: TObject);
begin
  Restore('c:\data\demo_restored.fdb', 'c:\temp\demo.fbk');
end;

See also

  • Firebird Using Firebird with FPC/Lazarus sqldb.


LCL Components
Component Tab Components
Standard TMainMenu • TPopupMenu • TButton • TLabel • TEdit • TMemo • TToggleBox • TCheckBox • TRadioButton • TListBox • TComboBox • TScrollBar • TGroupBox • TRadioGroup • TCheckGroup • TPanel • TFrame • TActionList
Additional TBitBtn • TSpeedButton • TStaticText • TImage • TShape • TBevel • TPaintBox • TNotebook • TLabeledEdit • TSplitter • TTrayIcon • TControlBar • TFlowPanel • TMaskEdit • TCheckListBox • TScrollBox • TApplicationProperties • TStringGrid • TDrawGrid • TPairSplitter • TColorBox • TColorListBox • TValueListEditor
Common Controls TTrackBar • TProgressBar • TTreeView • TListView • TStatusBar • TToolBar • TCoolBar • TUpDown • TPageControl • TTabControl • THeaderControl • TImageList • TPopupNotifier • TDateTimePicker
Dialogs TOpenDialog • TSaveDialog • TSelectDirectoryDialog • TColorDialog • TFontDialog • TFindDialog • TReplaceDialog • TTaskDialog • TOpenPictureDialog • TSavePictureDialog • TCalendarDialog • TCalculatorDialog • TPrinterSetupDialog • TPrintDialog • TPageSetupDialog
Data Controls TDBNavigator • TDBText • TDBEdit • TDBMemo • TDBImage • TDBListBox • TDBLookupListBox • TDBComboBox • TDBLookupComboBox • TDBCheckBox • TDBRadioGroup • TDBCalendar • TDBGroupBox • TDBGrid • TDBDateTimePicker
Data Access TDataSource • TCSVDataSet • TSdfDataSet • TBufDataset • TFixedFormatDataSet • TDbf • TMemDataset
System TTimer • TIdleTimer • TLazComponentQueue • THTMLHelpDatabase • THTMLBrowserHelpViewer • TAsyncProcess • TProcessUTF8 • TProcess • TSimpleIPCClient • TSimpleIPCServer • TXMLConfig • TEventLog • TServiceManager • TCHMHelpDatabase • TLHelpConnector
Misc TColorButton • TSpinEdit • TFloatSpinEdit • TArrow • TCalendar • TEditButton • TFileNameEdit • TDirectoryEdit • TDateEdit • TTimeEdit • TCalcEdit • TFileListBox • TFilterComboBox • TComboBoxEx • TCheckComboBox • TButtonPanel • TShellTreeView • TShellListView • TXMLPropStorage • TINIPropStorage • TJSONPropStorage • TIDEDialogLayoutStorage • TMRUManager • TStrHolder
LazControls TCheckBoxThemed • TDividerBevel • TExtendedNotebook • TListFilterEdit • TListViewFilterEdit • TLvlGraphControl • TShortPathEdit • TSpinEditEx • TFloatSpinEditEx • TTreeFilterEdit • TExtendedTabControl •
RTTI TTIEdit • TTIComboBox • TTIButton • TTICheckBox • TTILabel • TTIGroupBox • TTIRadioGroup • TTICheckGroup • TTICheckListBox • TTIListBox • TTIMemo • TTICalendar • TTIImage • TTIFloatSpinEdit • TTISpinEdit • TTITrackBar • TTIProgressBar • TTIMaskEdit • TTIColorButton • TMultiPropertyLink • TTIPropertyGrid • TTIGrid
SQLdb TSQLQuery • TSQLTransaction • TSQLScript • TSQLConnector • TMSSQLConnection • TSybaseConnection • TPQConnection • TPQTEventMonitor • TOracleConnection • TODBCConnection • TMySQL40Connection • TMySQL41Connection • TMySQL50Connection • TMySQL51Connection • TMySQL55Connection • TMySQL56Connection • TMySQL57Connection • TSQLite3Connection • TIBConnection • TFBAdmin • TFBEventMonitor • TSQLDBLibraryLoader
Pascal Script TPSScript • TPSScriptDebugger • TPSDllPlugin • TPSImport_Classes • TPSImport_DateUtils • TPSImport_ComObj • TPSImport_DB • TPSImport_Forms • TPSImport_Controls • TPSImport_StdCtrls • TPSCustomPlugin
SynEdit TSynEdit • TSynCompletion • TSynAutoComplete • TSynMacroRecorder • TSynExporterHTML • TSynPluginSyncroEdit • TSynPasSyn • TSynFreePascalSyn • TSynCppSyn • TSynJavaSyn • TSynPerlSyn • TSynHTMLSyn • TSynXMLSyn • TSynLFMSyn • TSynDiffSyn • TSynUNIXShellScriptSyn • TSynCssSyn • TSynPHPSyn • TSynTeXSyn • TSynSQLSyn • TSynPythonSyn • TSynVBSyn • TSynAnySyn • TSynMultiSyn • TSynBatSyn • TSynIniSyn • TSynPoSyn
Chart TChart • TListChartSource • TRandomChartSource • TUserDefinedChartSource • TCalculatedChartSource • TDbChartSource • TChartToolset • TChartAxisTransformations • TChartStyles • TChartLegendPanel • TChartNavScrollBar • TChartNavPanel • TIntervalChartSource • TDateTimeIntervalChartSource • TChartListBox • TChartExtentLink • TChartImageList
IPro TIpFileDataProvider • TIpHtmlDataProvider • TIpHttpDataProvider • TIpHtmlPanel
Virtual Controls TVirtualDrawTree • TVirtualStringTree • TVTHeaderPopupMenu