unit uDASQLiteInterfaces; {----------------------------------------------------------------------------} { Data Abstract Library - Core Library } { } { compiler: Delphi 6 and up, Kylix 3 and up } { platform: Win32, Linux } { } { (c)opyright RemObjects Software. all rights reserved. } { } { Using this code requires a valid license of the Data Abstract } { which can be obtained at http://www.remobjects.com. } {----------------------------------------------------------------------------} {$I DataAbstract.inc} interface uses uDAInterfaces, uDAEngine, uROClasses; type { IDASQLiteConnection For identification purposes Implemented by all SQLite connections } IDASQLiteConnection = interface(IDAConnection) ['{C6249278-7BBB-4E4F-849B-A9AA7C9ACD66}'] end; TDASQLiteDriver = class(TDAEDriver) protected function GetDefaultConnectionType(const AuxDriver: string): string; override; {$IFNDEF FPC_SAFECALL_BUG}safecall;{$ENDIF} end; TDASQLiteConnection = class(TDAEConnection, IDAFileBasedDatabase, IDASQLiteConnection) protected procedure DoGetTableNames(out List: IROStrings); override; procedure DoGetStoredProcedureNames(out List: IROStrings); override; procedure DoGetViewNames(out List: IROStrings); override; //IDAFileBasedDatabase function GetFileExtensions: IROStrings; end; function SQLite_GetFileExtensions: IROStrings; procedure SQLite_GetObjectNames(Query: IDADataset;AList: IROStrings; AObjectType: TDAObjecttype); const SQLite_DriverType = 'SQLite'; implementation uses SysUtils; function SQLite_GetFileExtensions: IROStrings; begin Result := TROStrings.Create; result.Add('*.SQB;*.DB3;*.DB;*.DBB;SQLite Database (*.sqb,*.db3,*.db,*.dbb)'); result.Add('*.*;All files (*.*)'); end; procedure SQLite_GetObjectNames(Query: IDADataset;AList: IROStrings; AObjectType: TDAObjecttype); begin try case AObjectType of dotTable: Query.SQL := 'SELECT name FROM sqlite_master WHERE type="table" ORDER BY name'; dotView: Query.SQL := 'SELECT name FROM sqlite_master WHERE type="view" ORDER BY name'; dotProcedure: Exit; else end; Query.Open; while not Query.EOF do begin AList.Add(Trim(Query.Fields[0].AsString)); Query.Next; end; finally Query:=nil; end; end; { TDASQLiteDriver } function TDASQLiteDriver.GetDefaultConnectionType( const AuxDriver: string): string; begin Result:= SQLite_DriverType; end; { TDASQLiteConnection } procedure TDASQLiteConnection.DoGetStoredProcedureNames(out List: IROStrings); begin inherited; SQLite_GetObjectNames(GetDatasetClass.Create(Self),List,dotProcedure); end; procedure TDASQLiteConnection.DoGetTableNames(out List: IROStrings); begin inherited; SQLite_GetObjectNames(GetDatasetClass.Create(Self),List,dotTable); end; procedure TDASQLiteConnection.DoGetViewNames(out List: IROStrings); begin inherited; SQLite_GetObjectNames(GetDatasetClass.Create(Self),List,dotView); end; function TDASQLiteConnection.GetFileExtensions: IROStrings; begin Result:=SQLite_GetFileExtensions; end; end.