Description | Hierarchy | Fields | Methods | Properties |
type TSqlitePassDatabase = class(TComponent)
The TSqlitePassDatabase
component is the main link between your application and the sqlite library. It currently supports sqlite engine version 3.xx and gives you direct acces to a wide range of sqlite databases created using database management progams like kexi, sqlite administrator, sqliteToolbox...etc. With proper setting, you can also use it to read and write to your own custom sqlite databases.
![]() |
Constructor Create(AOwner : TComponent); override; |
![]() |
Destructor Destroy; override; |
![]() |
Function AttachDatabase(FAttachedDatabase, DatabaseAlias: String): Boolean; |
![]() |
Function Compact: Integer; |
![]() |
Function CreateAggFunction(FuncName: String; ArgCount: ShortInt; FuncStep: TFuncHandler; FuncFinal: TFuncFinalizer; UserData: Pointer; DefaultEncoding: Byte = SQLITE_ANY): Boolean; |
![]() |
Function CreateDatabase(DbName: String; DbType: TSqlitePassDatabaseType; DbEncoding: TSqlitePassEncoding = UTF8; PageSize: TSqlitePassPageSize = 4096; AutoVacuum: TSqlitePassAutoVacuumType = avNone): Boolean; |
![]() |
Function CreateFunction(FuncName: String; ArgCount: ShortInt; Func: TFuncHandler; UserData: Pointer; DefaultEncoding: Byte = SQLITE_ANY): Boolean; |
![]() |
Function DeleteDatabase(Const DbName: String): Boolean; |
![]() |
Function DeleteFunction(FuncName: String): Boolean; |
![]() |
Function DetachDatabase(DatabaseAlias: String): Boolean; |
![]() |
Function IsSystemTable(TableName: String): Boolean; |
![]() |
procedure CheckIntegrity(MsgList: TStringList; MaxErrorCount: Integer = 100); |
![]() |
Procedure Close; |
![]() |
Procedure Open; |
![]() |
procedure RefreshDefinitions; |
![]() |
Procedure Loaded; override; |
![]() |
Procedure Notification(AComponent: TComponent; Operation: TOperation); Override; |
![]() |
property Connected : Boolean Read GetFConnected Write SetFConnected Default False; |
![]() |
property Database : String Read FDatabase Write SetFDatabase; |
![]() |
property DatabaseError: TSqlitePassDatabaseError Read FDatabaseError; |
![]() |
property Databases: TSqlitePassDatabasesAttached Read FDatabases; |
![]() |
property DatabaseType : TSqlitePassDatabaseType Read FDatabaseType Write FDatabaseType; |
![]() |
property Datasets: TSqlitePassDatasets Read FDatasets Write FDatasets; |
![]() |
property DatatypeOptions : TSqlitePassDatabaseDataTypeOptions Read FDatatypeOptions Write FDatatypeOptions; |
![]() |
property Engine: TSqlitePassEngine Read GetFEngine; |
![]() |
property IndexDefs: TSqlitePassDatabaseIndexDefs Read FIndexDefs Write FIndexDefs; |
![]() |
property OnAfterConnect : TConnectEvent Read FAfterConnect Write FAfterConnect; |
![]() |
property OnAfterDisconnect : TConnectEvent Read FAfterDisconnect Write FAfterDisconnect; |
![]() |
property OnBeforeConnect : TConnectEvent Read FBeforeConnect Write FBeforeConnect; |
![]() |
property OnBeforeDisconnect : TConnectEvent Read FBeforeDisconnect Write FBeforeDisconnect; |
![]() |
property OnDataTypeConversion : TDataTypeConversion Read FDataTypeConversion Write FDataTypeConversion; |
![]() |
property Options : TSqlitePassDatabaseOptions Read FOptions Write FOptions; |
![]() |
property QueryDefs: TSqlitePassQueryDefs Read FQueryDefs Write FQueryDefs; |
![]() |
property QueryTimeout : Integer Read FQueryTimeout Write FQueryTimeout; |
![]() |
property ReadOnly : Boolean Read FReadOnly Write SetFReadOnly default False; |
![]() |
property ShowSystemObjects : Boolean Read FShowSysObjects Write SetFShowSysObjects; |
![]() |
property SQLiteLibrary : String Read FSQLiteLibrary Write SetFSQLiteLibrary; |
![]() |
property SQLStmtDefs: TSqlitePassSQLStmtDefs Read FSQLStmtDefs Write FSQLStmtDefs; |
![]() |
property SystemEncoding: TSqlitePassSystemEncoding Read FSystemEncoding; |
![]() |
property TableDefs: TSqlitePassTableDefs Read FTableDefs Write FTableDefs; |
![]() |
property Translator: TSqlitePassTranslator Read FTranslator; |
![]() |
property Triggers: TSqlitePassTriggers Read FTriggers Write FTriggers; |
![]() |
property VersionInfo : TSqlitePassDatabaseVersionInfo Read FVersionInfo Write FVersionInfo; |
![]() |
property Views: TSqlitePassViews Read FViews Write FViews; |
![]() |
Constructor Create(AOwner : TComponent); override; |
—– Constructor / Destructor —– |
![]() |
Destructor Destroy; override; |
![]() |
Function AttachDatabase(FAttachedDatabase, DatabaseAlias: String): Boolean; |
Enables to attach one or several foreign databases to the current one. The attached databases must be compatible with the current one (the databases must have been created with the same database manager application). Once a database is attached, its content becomes available as part of the current database. Then you can access to tables, queries... as if they were part of the main database. Usage : |
![]() |
Function Compact: Integer; |
Compacts the database content and free unused space |
![]() |
Function CreateAggFunction(FuncName: String; ArgCount: ShortInt; FuncStep: TFuncHandler; FuncFinal: TFuncFinalizer; UserData: Pointer; DefaultEncoding: Byte = SQLITE_ANY): Boolean; |
CreateAggFunc References a new Aggregate User Defined function in the Sqlite Engine API As an Example, you can use an SumOdd function to get the Sum of Odd Values : procedure TMainForm.Button1Click(Sender: TObject); begin SumOddResult := 0; db.CreateAggFunction('SumOdd', 1, @SumOddStep, @SumOddFinal, @SumOddResult); end; procedure SumOddFinal(Context: Pointer); cdecl; begin // Send back the final result to SQLite Engine SqlitePassApi_v3.SqliteDbv3_result_int(Context,SumOddResult); // Reset the value for another query SumOddResult := 0; end; |
![]() |
Function CreateDatabase(DbName: String; DbType: TSqlitePassDatabaseType; DbEncoding: TSqlitePassEncoding = UTF8; PageSize: TSqlitePassPageSize = 4096; AutoVacuum: TSqlitePassAutoVacuumType = avNone): Boolean; |
Creates a new database |
![]() |
Function CreateFunction(FuncName: String; ArgCount: ShortInt; Func: TFuncHandler; UserData: Pointer; DefaultEncoding: Byte = SQLITE_ANY): Boolean; |
CreateFunc References a new scalar User Defined function in the Sqlite Engine API As an Example, you can use an IsOdd function to filter the records returned by a query : |
![]() |
Function DeleteDatabase(Const DbName: String): Boolean; |
Deletes a database file. Use with caution... |
![]() |
Function DeleteFunction(FuncName: String): Boolean; |
Remove a previously referenced User Defined Function |
![]() |
Function DetachDatabase(DatabaseAlias: String): Boolean; |
Detaches a previously attached database. |
![]() |
Function IsSystemTable(TableName: String): Boolean; |
Returns True if the Table is a system table |
![]() |
procedure CheckIntegrity(MsgList: TStringList; MaxErrorCount: Integer = 100); |
Checks the database integrity and returns the results messages in MsgList |
![]() |
Procedure Close; |
Same as Connected := False |
![]() |
Procedure Open; |
Same as Connected := True |
![]() |
procedure RefreshDefinitions; |
Updates the database definition content (TableDefs, QueryDefs...) from file |
![]() |
Procedure Loaded; override; |
![]() |
Procedure Notification(AComponent: TComponent; Operation: TOperation); Override; |
![]() |
property Connected : Boolean Read GetFConnected Write SetFConnected Default False; |
Set this property to True to connect the database defined in the database property. Set it to False to disconnect the database and all the datasets associated with it. You can also verify if a database is |
![]() |
property Database : String Read FDatabase Write SetFDatabase; |
Represents the physical |
![]() |
property DatabaseError: TSqlitePassDatabaseError Read FDatabaseError; |
A utility object to log errors |
![]() |
property Databases: TSqlitePassDatabasesAttached Read FDatabases; |
A collection of attached database to the current one |
![]() |
property DatabaseType : TSqlitePassDatabaseType Read FDatabaseType Write FDatabaseType; |
Represents the database type detected from the database file extension you are using. (*.kexi for kexi database for example). Once the database type is recognised, the TsqlitePassDatabase component sets this property and creates an internal translator to take care of the database specifications. You can also define this property by yourself if the file extension doesn't match the correct database type. |
![]() |
property Datasets: TSqlitePassDatasets Read FDatasets Write FDatasets; |
A collection of all the |
![]() |
property DatatypeOptions : TSqlitePassDatabaseDataTypeOptions Read FDatatypeOptions Write FDatatypeOptions; |
One of the main difficulties when working with Sqlite databases is to detect and translate properly the fields.datatypes since sqlite datatype are not formely defined. SqlitePass implements several ways to define a datatype. The Database.DatatypeOptions property gives you the opportunity to set custom or default behaviors for a given database and lets you also define how fields.datatype will be retrieved and translated into pascal datatypes using TranslationRules and CustomFieldDefs |
![]() |
property Engine: TSqlitePassEngine Read GetFEngine; |
Internal object to access the sqlite |
![]() |
property IndexDefs: TSqlitePassDatabaseIndexDefs Read FIndexDefs Write FIndexDefs; |
The |
![]() |
property OnAfterConnect : TConnectEvent Read FAfterConnect Write FAfterConnect; |
—– Events —– |
![]() |
property OnAfterDisconnect : TConnectEvent Read FAfterDisconnect Write FAfterDisconnect; |
![]() |
property OnBeforeConnect : TConnectEvent Read FBeforeConnect Write FBeforeConnect; |
![]() |
property OnBeforeDisconnect : TConnectEvent Read FBeforeDisconnect Write FBeforeDisconnect; |
![]() |
property OnDataTypeConversion : TDataTypeConversion Read FDataTypeConversion Write FDataTypeConversion; |
![]() |
property Options : TSqlitePassDatabaseOptions Read FOptions Write FOptions; |
Represents the database optional settings. |
![]() |
property QueryDefs: TSqlitePassQueryDefs Read FQueryDefs Write FQueryDefs; |
The |
![]() |
property QueryTimeout : Integer Read FQueryTimeout Write FQueryTimeout; |
![]() |
property ReadOnly : Boolean Read FReadOnly Write SetFReadOnly default False; |
Same as classic dataset behavior |
![]() |
property ShowSystemObjects : Boolean Read FShowSysObjects Write SetFShowSysObjects; |
![]() |
property SQLiteLibrary : String Read FSQLiteLibrary Write SetFSQLiteLibrary; |
Represents an alternative library file to be used instead of the default one. By default, sqlitepassDatabase tries to use the sqlitepass3.dll or libsqlitepass3.so file located in the system path directory (..\windows\system32\ or ..\user\lib for example). Enter a complete library file path to use a different library. From version 0.28 TsqlitePassDatabase needs the sqlite library compiled with the ENABLE_METADATA precompiler directive. These libraries are available from http://source.online.free.fr or you can compile your own following the tutorial available on the same internet site. |
![]() |
property SQLStmtDefs: TSqlitePassSQLStmtDefs Read FSQLStmtDefs Write FSQLStmtDefs; |
![]() |
property SystemEncoding: TSqlitePassSystemEncoding Read FSystemEncoding; |
sysUTF8 : For Delphi, prior Delphi 2009, and Lazarus, Database.SystemEncoding default value is sysUTF8. sysUTF16 : For Delphi 2009 and up : Database.SystemEncoding default value is sysUTF16.
|
![]() |
property TableDefs: TSqlitePassTableDefs Read FTableDefs Write FTableDefs; |
The |
![]() |
property Translator: TSqlitePassTranslator Read FTranslator; |
translation object used to get or set data that depend on the DatabaseType property |
![]() |
property Triggers: TSqlitePassTriggers Read FTriggers Write FTriggers; |
The TriggerDefs property is a collection that gives you access to the |
![]() |
property VersionInfo : TSqlitePassDatabaseVersionInfo Read FVersionInfo Write FVersionInfo; |
![]() |
property Views: TSqlitePassViews Read FViews Write FViews; |
The ViewDefs property is a collection that gives you access to the |