After following the instructions in the five sections of this document, you will have created a
MySQL database and
TestStand configured for logging results. Once you have completed all of the steps in this document, execute a test sequence and then use the Database Viewer, to view the results that have been logged to the MySQL database.
Note: These instructions assume
MySQL Server 5.6,
MyODBC 5.3 Driver and
TestStand 2013 are installed.
- Installation
- Download MySQL Installer .
- Install MySQL Tools as Developer. Open Database Connectivity (ODBC) / Connector must be correctly installed, otherwise download it from MySQL and install it separately.
Note: When using Windows 64bit install the ODBC Driver for 64bit first, reboot the system and install the 32 bit driver afterwards..
- Set a password for your root.
- Creating the Database and User
- Open MySQL Workbench: Start>>All Programs>>MySQL>> MySQL Workbench 6.1 CE.
- Manage a new connection: Database>>Manage Connections and press "New".
- You should see the following screen:
- Open new connection by double clicking it.
- Create new database by clicking on the button Create new Schema in the connected Server and name it, e.g. TestStand_MySQL_DB. Press Apply.
- Select Users and Privileges from the upper left-hand pane.
- Select Add Account from the bottom of the window.
- Fill in the text for MySQL User and Password
- After filling in the fields shown, click Apply changes.
- Click on the Schema Privileges Tab.
- Click on Add Entry, and you should see:
- Select TestStand_MySQL_DB and press OK. Add now the wanted privileges for this database.
(for this tutorial: use Select All) - Press Apply.
- Restart service for the changes to take effect (Click on Stop Service and then Start Service).
- ODBC Data Source Administrator:
- Use the ODBC Data Source Administrator to create a Data Source Name (DSN) and the corresponding database: Start>>Settings>>Control Panel>>Administrative Tools.
- Double-click the ODBC icon Data Sources (ODBC) to open the ODBC Data Source Administrator dialog box.
- Select the System DSN tab when you want data source visible to all users on this machine.
Select the User DSN tab when you want data source visible only for this users. - Click Add and select MySQL ODBC Driver from the list:
- If MySQL ODBC Driver does not exist, install Connector/ODBC (Select the correct bits according to your application).
- Click Finish.
- Fill in the dialog box shown below with a unique Data Source Name of your choosing. teststand2 is used in this example.
- Type in the user name and password for the user created above. Both are case-sensitive.
- Select the database created above: teststand_mysql_db.
- Click Test to make sure the connection works. You should see the following message: Success; Connection was made!
- TestStand Database Options:
- Use the TestStand Sequence Editor to configure TestStand to use the newly created Data Source:
Name: Open the TestStand Sequence Editor, and select Configure>>Result Processing - Add new Database Logging and Enable Database Logging by selecting the corresponding check box.
- Click on Database Option >> Data Link tab. Use this tab to create a data link for TestStand.
- Select MySQL from the drop down list box for Database Management System and press Build.
- Click on the Provider Tab of the Data Link Properties dialog box.
- Select Microsoft OLE DB Provider for ODBC Drivers as shown below:
- Click Next.
- Select the Data Source Name created in ODBC Data Source Administrator under the System
DSN/System Data Sources. In this example MySQL_DB_For_TestStand is used. - Type in the User Name and password, and then click Test Connection.
- Click the OK button two times to close the Data Link Properties dialog box.
- Click the Schemas Tab and enable the MySQL Insert (NI) schema.
- Click OK button to close the Database Options dialog box.
- Creating Database Tables
- Use the Database Viewer built into TestStand to view data, edit database table properties, and
execute SQL commands on the database. Open the Database Viewer by selecting Configure>>Report Processing>> (Database to view) >> Database Options - Select View Data from the Data Link tab in the Database Options dialog box.
- Select File>>Open and select SQL (*.sql) files from the Files of Type field at the bottom of the
dialog box. - Open MySQL Create Insert Result Tables.sql from the %TestStand%/Components/
Models/TestStandModels/Database directory. - Press the Execute SQL Commands button (green arrow) to execute the commands.
- Review the results of the SQL commands in the SQL History control of the Execute SQL window.
- Close the Execute SQL window.
- The created tables can now be viewed in the Database Viewer. Select Window>>Refresh to verify that the tables were created successfully
- Run Your Program or an Example to and check if data is logged to database
Additional Information
If you receive this error message when trying to access the mySQL database using the Database Viewer:
And your Connection String Expression looks like this:
Try to change the Database String Expression to:
"Driver={MySQL ODBC <version> ANSI Driver};Server=<server IP>;Database=<database name>;User=<user name>;password=<password>"
Where:
<version> is replaced by the mySQL driver version.
<server IP> is replaced by the IP address of your mySQL server.
<database name> is replaced by the name of the database on the database server.
<user name> is replaced by your user name to log into the database server and
<password> is replaced by your password for the database server account.
The result should look like this:
Afterwards, verify that result recording still works and you can view the data in the database by clicking View Data.