|
- Overview
- Importing the structure of files
- The import steps
- Taking into account the evolutions of the SQLite database
- Programming
- 1. Opening the connection
- 2. Running queries
- 3. Retrieving the result
- 4. Closing the connection
SQLite: Programming with HFSQL functions
Available only with this kind of connection
To use an SQLite database with Native Connector (also called Native Access), the structure of SQLite tables must be imported into the data model editor. Differences compared to SQL programming: The queries are not required to handle the SQLite data. Indeed, the HFSQL functions can be directly used to read data, perform searches, implement filters, ... However, the structure of SQLite files must be imported into the data model editor. Remark: From version 19, HFSQL is the new name of HyperFileSQL. Importing the structure of files The import steps To perform this import: - Open the data model editor ("Project .. Load the analysis"). Start the data model editor: click
among the quick access buttons. - In the data model editor, select "Structures of files .. Import the descriptions of files/tables".On the "Analysis" pane, in the "Creation" group, expand "Import" and select "Import the descriptions of files/tables".
- The wizard starts. A connection to the SQLite database is automatically established and associated with the files imported into the analysis. This connection will have to be used to handle the SQLite data file by programming.
In the different wizard screens, choose the following options:- Data source: External database.
- The data in current format will be used by the application.
- Select the "Native Access for SQLite" type, the name of the SQLite file and the directory of the file. The extension of this file can be db, db2, db3, sdb, sqlite, ...
- When the connection is established, select the tables that will be imported into the analysis. These tables can be handled by programming with the HyperFileSQL functions of WLanguage. These tables will be displayed in blue in the data model editor.
In the different wizard screens, choose the following options:- Type of database: SQLite.
- Characteristics of the connection: Data server, User and password, database.
- The application will access the data in the current format.
- When the connection is established, all you have to do is select the tables that will be imported into the WINDEV or WEBDEV analysis. These tables can be handled by programming with the HFSQL functions of WLanguage. These tables will be displayed in blue in the data model editor.
Taking into account the evolutions of the SQLite database To take into account the evolutions of tables imported into the data model editor, select "Structure of files .. Synchronize the analysis with the external databases".
To take into account the evolutions of the tables imported into the data model editor, on the "Analysis" pane, in the "Analysis" group, expand "Synchronization" and select "Update the analysis from the external databases". A wizard starts, allowing you to: - analyze the differences for the imported tables.
- analyze the differences for all the SQLite tables.
1. Opening the connection To establish the connection to the SQLite database, use HOpenConnection and specify the name of the connection to open. The connection name was defined when importing the structure of files into the analysis. To modify some parameters of this connection (user name or password for example), call HConnect. Remark: If you try to read the file directly ( HReadFirst, ...), the connection associated with the file description in the analysis will be automatically opened. - HExecuteQuery: is used to run a preset query with the query editor.
- HExecuteSQLQuery: is used to run a query by specifying the SQL code of query and the name that will be assigned to this SQL code.
// Initialize the "Customer_84" query HExecuteQuery(CUSTOMER_84, "SQLiteDatabase", hQueryWithoutCorrection) HExecuteSQLQuery(CustomerQry, "SQLiteDatabase", hQueryWithoutCorrection, ... "SELECT NAME FROM CUSTOMER")
3. Retrieving the result The records cannot be locked by the lock options of these functions. 4. Closing the connection HCloseConnection is used to close the connection to the database when all the necessary queries have been run.
This page is also available for…
|
|
|
| |
| Click [Add] to post a comment |
|
| |
|
| |
| |
| |
| |
| |
| |
| | |
| |