Class TSqlitePassDatabase

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TSqlitePassDatabase = class(TComponent)

Description

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.

Hierarchy

Overview

Methods

Public Constructor Create(AOwner : TComponent); override;
Public Destructor Destroy; override;
Public Function AttachDatabase(FAttachedDatabase, DatabaseAlias: String): Boolean;
Public Function Compact: Integer;
Public Function CreateDatabase(DbName: String; DbType: TSqlitePassDatabaseType; DbEncoding: TSqlitePassEncoding = UTF8; PageSize: TSqlitePassPageSize = 4096; AutoVacuum: TSqlitePassAutoVacuumType = 0): Boolean;
Public Function DeleteDatabase(Const DbName: String): Boolean;
Public Function DetachDatabase(DatabaseAlias: String): Boolean;
Public Function IsSystemTable(TableName: String): Boolean;
Public Procedure Close;
Public Procedure Open;
Public procedure RefreshDefinitions;
Protected Procedure Loaded; override;

Properties

Published property Connected : Boolean Read FConnected Write SetFConnected Default False;
Published property Database : String Read FDatabase Write SetFDatabase;
Public property DatabaseError: TSqlitePassDatabaseError Read FDatabaseError;
Public property Databases: TSqlitePassDatabasesAttached Read FDatabases;
Published property DatabaseType : TSqlitePassDatabaseType Read FDatabaseType Write FDatabaseType;
Public property Datasets: TSqlitePassDatasets Read FDatasets Write FDatasets;
Published property DatatypeOptions : TSqlitePassDatabaseDataTypeOptions Read FDatatypeOptions Write FDatatypeOptions;
Public property Engine: TSqlitePassEngine Read GetFEngine;
Public property IndexDefs: TSqlitePassDatabaseIndexDefs Read FIndexDefs Write FIndexDefs;
Published property OnAfterConnect : TConnectEvent Read FAfterConnect Write FAfterConnect;
Published property OnAfterDisconnect : TConnectEvent Read FAfterDisconnect Write FAfterDisconnect;
Published property OnBeforeConnect : TConnectEvent Read FBeforeConnect Write FBeforeConnect;
Published property OnBeforeDisconnect : TConnectEvent Read FBeforeDisconnect Write FBeforeDisconnect;
Published property OnDataTypeConversion : TDataTypeConversion Read FDataTypeConversion Write FDataTypeConversion;
Published property Options : TSqlitePassDatabaseOptions Read FOptions Write FOptions;
Public property QueryDefs: TSqlitePassQueryDefs Read FQueryDefs Write FQueryDefs;
Published property QueryTimeout : Integer Read FQueryTimeout Write FQueryTimeout;
Published property ReadOnly : Boolean Read FReadOnly Write SetFReadOnly default False;
Published property ShowSystemObjects : Boolean Read FShowSysObjects Write SetFShowSysObjects;
Published property SmartOpen : Boolean Read FSmartOpen Write FSmartOpen;
Published property SQLiteLibrary : String Read FSQLiteLibrary Write SetFSQLiteLibrary;
Public property SQLStmtDefs: TSqlitePassSQLStmtDefs Read FSQLStmtDefs Write FSQLStmtDefs;
Public property SystemEncoding: TSqlitePassSystemEncoding Read FSystemEncoding;
Public property TableDefs: TSqlitePassTableDefs Read FTableDefs Write FTableDefs;
Public property Translator: TSqlitePassTranslator Read FTranslator;
Public property Triggers: TSqlitePassTriggers Read FTriggers Write FTriggers;
Published property UserTag : Integer Read FUser Write SetFUser;
Published property VersionInfo : TSqlitePassDatabaseVersionInfo Read FVersionInfo Write FVersionInfo;
Public property Views: TSqlitePassViews Read FViews Write FViews;

Description

Methods

Public Constructor Create(AOwner : TComponent); override;

—– Constructor / Destructor —–

Public Destructor Destroy; override;
 
Public 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 : AttachDatabase(DatabasePath: String);

Public Function Compact: Integer;

Compacts the database content and free unused space

Public Function CreateDatabase(DbName: String; DbType: TSqlitePassDatabaseType; DbEncoding: TSqlitePassEncoding = UTF8; PageSize: TSqlitePassPageSize = 4096; AutoVacuum: TSqlitePassAutoVacuumType = 0): Boolean;

Creates a new database

Public Function DeleteDatabase(Const DbName: String): Boolean;
 
Public Function DetachDatabase(DatabaseAlias: String): Boolean;

Detaches a previously attached database.

Public Function IsSystemTable(TableName: String): Boolean;

Returns True if the Table is a system table

Public Procedure Close;

Same as Connected := False

Public Procedure Open;

Same as Connected := True

Public procedure RefreshDefinitions;

Updates the database definition content (TableDefs, QueryDefs...) from file

Protected Procedure Loaded; override;
 

Properties

Published property Connected : Boolean Read FConnected 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 connected using : if MyDatabase.Connected then...

Published property Database : String Read FDatabase Write SetFDatabase;

Represents the physical database file you want to connect. At design time, shows up a file selection dialog box.

Public property DatabaseError: TSqlitePassDatabaseError Read FDatabaseError;

A utility object to log errors

Public property Databases: TSqlitePassDatabasesAttached Read FDatabases;

A collection of attached database to the current one

Published 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.

Public property Datasets: TSqlitePassDatasets Read FDatasets Write FDatasets;

A collection of all the datasets that use the current database component

Published 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

Public property Engine: TSqlitePassEngine Read GetFEngine;

Internal object to access the sqlite engine

Public property IndexDefs: TSqlitePassDatabaseIndexDefs Read FIndexDefs Write FIndexDefs;

The IndexDefs property is a collection that gives you access to the indexes definitons stored in the database.

Published property OnAfterConnect : TConnectEvent Read FAfterConnect Write FAfterConnect;

—– Events —–

Published property OnAfterDisconnect : TConnectEvent Read FAfterDisconnect Write FAfterDisconnect;
 
Published property OnBeforeConnect : TConnectEvent Read FBeforeConnect Write FBeforeConnect;
 
Published property OnBeforeDisconnect : TConnectEvent Read FBeforeDisconnect Write FBeforeDisconnect;
 
Published property OnDataTypeConversion : TDataTypeConversion Read FDataTypeConversion Write FDataTypeConversion;
 
Published property Options : TSqlitePassDatabaseOptions Read FOptions Write FOptions;

Represents the database optional settings.

Public property QueryDefs: TSqlitePassQueryDefs Read FQueryDefs Write FQueryDefs;

The QueryDefs property is a collection that gives you access to the queries definitons stored in the database.

Published property QueryTimeout : Integer Read FQueryTimeout Write FQueryTimeout;
 
Published property ReadOnly : Boolean Read FReadOnly Write SetFReadOnly default False;

Same as classic dataset behavior

Published property ShowSystemObjects : Boolean Read FShowSysObjects Write SetFShowSysObjects;
 
Published property SmartOpen : Boolean Read FSmartOpen Write FSmartOpen;

When set to True, the TsqlitePassDataset will automatically takes care of opening the database connection if the database is not connected. Set it to False to manually control the database connection.

Published 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.

Public property SQLStmtDefs: TSqlitePassSQLStmtDefs Read FSQLStmtDefs Write FSQLStmtDefs;
 
Public property SystemEncoding: TSqlitePassSystemEncoding Read FSystemEncoding;

SystemEncoding lets you know how pascal compiler handles unicode strings.

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.

SystemEncoding show how the SQL statements sent to the database engine have to be encoded according to the compiler setting. You shouldn't have to care to much about this since the component will handle this for you.

Public property TableDefs: TSqlitePassTableDefs Read FTableDefs Write FTableDefs;

The TableDefs property is a collection that gives you access to the tables definitons stored in the database.

Public property Translator: TSqlitePassTranslator Read FTranslator;

translation object used to get or set data that depend on the DatabaseType property

Public property Triggers: TSqlitePassTriggers Read FTriggers Write FTriggers;

The TriggerDefs property is a collection that gives you access to the Triggers definitons stored in the database.

Published property UserTag : Integer Read FUser Write SetFUser;
 
Published property VersionInfo : TSqlitePassDatabaseVersionInfo Read FVersionInfo Write FVersionInfo;
 
Public property Views: TSqlitePassViews Read FViews Write FViews;

The ViewDefs property is a collection that gives you access to the views definitons stored in the database.


Generated by PasDoc 0.11.0 on 2009-10-08 22:34:50