Class TSQLiteDatabase

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TSQLiteDatabase = class(TObject)

Description

Class for handling SQLite database

Hierarchy

Overview

Methods

Public constructor Create(const FileName: String);
Public destructor Destroy; override;
Public procedure ExecSQL(const SQL : String);
Public function GetTable(const SQL: String; PrepareOnly: Boolean = false): TSQLiteTable;
Public function GetTableValue(const SQL: String): int64;
Public function GetTableString(const SQL: String): AnsiString;
Public procedure GetTableStrings(const SQL: String; const Value: TStrings);
Public function InTransaction: Boolean;
Public procedure Start(const name:String; const param: String = '');
Public procedure Commit(const name:String);
Public procedure Rollback(const name:String);
Public function LastInsertRowID: int64;
Public function LastChangedRows: int64;
Public function TotalChanges: int64;
Public procedure SetTimeout(Value: integer);
Public function Version: String;
Public procedure EnableLoadExtension(value: boolean);
Public procedure SetChunkSize(DatabaseName: ansistring; value: integer);
Public procedure AddCustomCollate(name: String; xCompare: TCollateXCompare);
Public Procedure AddSystemCollate;
Public procedure ParamsClear;
Public procedure AddParamInt(const name: String; value: int64);
Public procedure AddParamFloat(const name: String; value: double);
Public procedure AddParamText(const name: String; const value: AnsiString);
Public procedure AddParamNull(const name: String);
Public procedure AddParamBlobPtr(const name: String; buffer: pointer; len: integer);
Public procedure AddParamBlobText(const name: String; const value: AnsiString);
Public procedure AddParamBlob(const name: String; const value: TStream; len: integer);
Public function DBLoadHandle(SourceDB: TSQliteDB): integer;
Public function DBLoadFile(const FileName: String): integer;
Public function DBSaveHandle(DestinationDB: TSQliteDB): integer;
Public function DBSaveFile(const FileName: String): integer;
Public function DBBackupHandle(DestinationDB: TSQliteDB): integer;
Public function DBBackupFile(const FileName: String): integer;
Public procedure DbBackupStop;

Properties

Public property DB: TSQLiteDB read fDB;
Public property OnQuery: THookQuery read FOnQuery write FOnQuery;

Description

Methods

Public constructor Create(const FileName: String);

Class constructor. Pass filename of database. If databas not exists, then new one is created. If you pass empty string as filename, then temporary database is created. If you pass ':memory:' as filename, then temporary database in memory is created.

Warning: Pass FileName as AnsiString (if you are not using Unicode Delphi version) or as UnicodeString (on Delphi 2009 and higher)!

Public destructor Destroy; override;

Class descructor. Call Free instead.

Public procedure ExecSQL(const SQL : String);

Run SQL command without result. You can call before functions AddParam* for set query parameters.

Public function GetTable(const SQL: String; PrepareOnly: Boolean = false): TSQLiteTable;

Run SQL command with result. You can call before functions AddParam* for set query parameters. If you set PerpareOnly, then query is just prepared but first row is not fetched!

Public function GetTableValue(const SQL: String): int64;

Run SQL command and number from first field in first row is returned. You can call before functions AddParam* for set query parameters.

Public function GetTableString(const SQL: String): AnsiString;

Run SQL command and value from first field in first row is returned. You can call before functions AddParam* for set query parameters.

Public procedure GetTableStrings(const SQL: String; const Value: TStrings);

Run SQL command and values from first field in each row is filled to stringlist. You can call before functions AddParam* for set query parameters.

Public function InTransaction: Boolean;

Return True if database is in transaction state.

Public procedure Start(const name:String; const param: String = '');

Start transaction. You can modify transaction type by Param parameter. If you use non-empty Name parameter, then savepoint is used. Savepoint is named and can be nested.

Public procedure Commit(const name:String);

Commit transaction. If you use non-empty Name parameter, then savepoint is used. Savepoint is named and can be nested.

Public procedure Rollback(const name:String);

Rollback transaction. If you use non-empty Name parameter, then savepoint is used. Savepoint is named and can be nested.

Public function LastInsertRowID: int64;

Get ROWID of last inserted row.

Public function LastChangedRows: int64;

Return number of modified rows by last query.

Public function TotalChanges: int64;

Return number of modified rows starting by opened database connection.

Public procedure SetTimeout(Value: integer);

Set wait timeout. if database is locked, then it wait this timeout. If database is not released within this timeout, then error is returned.

Public function Version: String;

Return SQLite engine version.

Public procedure EnableLoadExtension(value: boolean);

Enable/disable suport for loaded extension libraries.

Public procedure SetChunkSize(DatabaseName: ansistring; value: integer);

Set chunk size for databaze file grow.

Public procedure AddCustomCollate(name: String; xCompare: TCollateXCompare);

Add custom sorting procedure as new Collate.

Public Procedure AddSystemCollate;

Add collate named SYSTEM for correct data sorting by user's locale

Public procedure ParamsClear;

Clear all query parameters.

Public procedure AddParamInt(const name: String; value: int64);

Add named query parameter of integer type.

Public procedure AddParamFloat(const name: String; value: double);

Add named query parameter of floating-point type.

Public procedure AddParamText(const name: String; const value: AnsiString);

Add named query parameter of string or binary type.

Public procedure AddParamNull(const name: String);

Add named query parameter with null value.

Public procedure AddParamBlobPtr(const name: String; buffer: pointer; len: integer);

Add named query parameter of BLOB type from the memory buffer.

Public procedure AddParamBlobText(const name: String; const value: AnsiString);

Add named query parameter of BLOB type from the binary string.

Public procedure AddParamBlob(const name: String; const value: TStream; len: integer);

Add named query parameter of BLOB type from the stream.

Public function DBLoadHandle(SourceDB: TSQliteDB): integer;
 
Public function DBLoadFile(const FileName: String): integer;
 
Public function DBSaveHandle(DestinationDB: TSQliteDB): integer;
 
Public function DBSaveFile(const FileName: String): integer;
 
Public function DBBackupHandle(DestinationDB: TSQliteDB): integer;
 
Public function DBBackupFile(const FileName: String): integer;
 
Public procedure DbBackupStop;
 

Properties

Public property DB: TSQLiteDB read fDB;

SQLite database handler.

Public property OnQuery: THookQuery read FOnQuery write FOnQuery;

Debug hook for log all called queries.


Generated by PasDoc 0.9.0 on 2018-03-13 21:07:28