|
|
|
|
|
- Overview
- Importing the structure of data files
- The import steps
- Take into account changes in the MySQL database
- Programming
- 1. Establishing the connection
- 2. Running queries
- 3. Retrieving the result
- 4. Closing the connection
- Tip in Linux
MySQL Native Connector: Programming with HFSQL functions
Available only with this kind of connection
To use a MySQL database with the Native Connector (or "Native Access"), the structure of MySQL tables must be imported into the WINDEV or WEBDEV analysis. Differences from SQL programming: To manipulate MySQL data, queries are not mandatory. In fact, you can directly use HFSQL functions to read your data, perform searches, filters, etc. However, you will need to import the MySQL file structure into your WINDEV or WEBDEV analysis. Importing the structure of data files The import steps To perform this import: - Launch the data model editor: click on
among the quick access buttons. - On the "Analysis" tab, in the "Creation" group, expand "Import" and select "Import file/table descriptions...".
- The wizard starts. A connection to the MySQL database is automatically established and associated with the data files imported into the analysis. This connection will have to be used to handle the MySQL data file programmatically.
In the different steps of the wizard, choose the following options: - Database type: MySQL.
- Connection features: 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 through programming with the HFSQL functions of WLanguage. These tables will be displayed in blue in the data model editor.
Take into account changes in the MySQL database To take account of changes to tables imported into the data model editor, in the "Analysis" pane, in the "Analysis" group, pull down "Synchronization" and select "Update analysis from external databases". A wizard starts, allowing you to: - analyze the differences for the imported tables,
- analyze the differences for all the MySQL tables.
1. Establishing the connection To establish the connection to the MySQL database, call HOpenConnection and specify the name of the connection to open. The connection name was defined when importing the structure of files into the analysis. Caution: If you use another syntax, the name of the database to be used must be specified. To modify some parameters of this connection (username or password for example), call HConnect. Remarks: - If you try to read the file directly (HReadFirst, ...), the connection associated with the file description in the analysis will be automatically opened.
- You have the ability to set the "Server Port", "Unix Socket" and "Client Flag" parameters for the connection to the MySQL server. Simply add the corresponding strings in the extended information of the connection (HDescribeConnection or HOpenConnection).
Example 1: "Server Port=3306;" to connect to port 3306 of the MySQL server. Example 2: "Server Port=3306; Client Flag=0;" ... For more details, see the documentation about MySQL (keyword = 'mysql_real_connect'). - The management mode of the Unicode items can be configured during the connection. Simply add the "WD Unicode Support" option to the extended information of the connection (HDescribeConnection or HOpenConnection).
- If "WD Unicode Support = 0", the management of the Unicode format is disabled for the connection. All the values will be converted (if necessary) by the server into the default character set. In this case, the performance is improved but the Unicode items are not supported.
- If "WD Unicode Support = 1" (default value), the management of the Unicode format is enabled for the connection. All the exchanges with the server will be performed in Unicode. The possible conversions are managed by the Native Connector.
- The size of the cache can be specified in the optional information of the connection with the following keyword "WD Cache Size". In this case, the parameter specified in CtCacheSize is ignored.
Example:
"WD Cache Size = 10000; Server Port=3306;"
2. Running queries - HEExecuteQuery: executes a predefined query using the query editor.
- HExecuteQuerySQL: allows you to execute a query by directly specifying the query's SQL code, and the name to be allocated to this SQL code.
HExecuteQuery(CUSTOMER_84, "MYSQLDatabase", hQueryWithoutCorrection)
HExecuteSQLQuery(CustomerQry, "MYSQLDatabase", hQueryWithoutCorrection, ...
"SELECT NAME FROM CUSTOMER")
4. Closing the connection HCloseConnection is used to close the connection to the database once all the necessary queries have been run.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|