Logging TestStand Results to a MySQL Database
Overview
After following the instructions in the four sections of this document, you will have 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, described below, to view the results that have been logged to the MySQL database.
Note: These instructions assume MySQL Server 4.1, MyODBC 3.51 Driver and TestStand 3.1 are installed.
Table of Contents
Creating the Database and User
On your MySQL server:1. Select Start>>Programs>>MySQL>>MySQL 4.1>>MySQL Command Line Client.
2. Type in your root password.
3. At the MySQL command line type in “CREATE DATABASE myTestDB;”.
4. Select Start>>Programs>>MySQL>>MySQL Administrator.
5. You should see the following screen:

6. Type in your password and press OK.
7. Select User Administration from the upper left-hand pane.
8. Select New User from the bottom of the window.
9. Fill in the text for MySQL User, Password, etc....

10. After filling in the fields shown, click Apply changes.
11. Click on the Schema Privileges Tab.
12. Click on the MySQL Schema, if there is one, and you should see:

13. Select myTestDB and push the >> button to assign all privileges to myTestDB schema for teststandOp. You should see privileges move to the center column.
14. Push the Apply Changes button.
15. 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 DSN and the corresponding database:
1. Select Start>>Settings>>Control Panel>>Administrative Tools.
2. Double-click the ODBC icon to open the ODBC Data Source Administrator dialog box.

3. Select the System DSN Tab.
4. Click Add.
5. Select MySQL ODBC 3.51 Driver from the list.

6. Click Finish.
7. Fill in the dialog box shown below with a unique Data Source Name of your choosing. "teststand2" was used in this example.
8. Type in the User name for the user created above. The User name is case-sensitive.
9. Type in the password you selected for this user.
10. Select the database created above, myTestDB.

Note: This screenshot shows "test2" as the selected database. Be sure to select "myTestDB" as the database.
11. Click Test to make sure the connection works. You should see the following message: “Success; Connection was made!”.
Setting Database Options
Use the TestStand Sequence Editor to configure TestStand to use the newly created Data Source Name:
1. Open TestStand Sequence Editor, and select Configure>>Database Options.
2. Enable Database Logging by unchecking the "Disable Database Logging" check box.
3. Click on the Data Link Tab. Use this tab to create a data link for TestStand to use.
4. Select MySQL from the drop down list box for Database Management System.
5. Select the Build button.
6. Click the Provider Tab of the Data Link Properties dialog box.
7. Select Microsoft OLE DB Provider for ODBC Drivers as shown below:

8. Click the Connection Tab.
9. Select the Data Source Name created in ODBC Data Source Administrator under the System DSN/System Data Sources. In this example “teststand2” is used.
10. Type in the User Name and password, and then click Test Connection. You should see something like:

11. Click two OK buttons to close the Data Link Properties dialog box.
12. Click the Schemas Tab and enable the MySQL Insert (NI) schema.
13. 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:
1. Open the Database Viewer by selecting Configure>>Database Options.
2. Select View Data from the Data Link tab in the Database Options dialog box.
3. Select File>>Open and select SQL (*.sql) files from the Files of Type field at the bottom of the dialog box.
4. Open MySQL Create Insert Result Tables.sql from the <TestStand>/Components/NI/Models/TestStandModels/Database directory.

[+] Enlarge Image
5. Push the GO button to execute the commands.
6. Review the results of the SQL commands in the SQL History control of the Execute SQL window.
7. Close the Execute SQL window.
8. The created tables can now be viewed in the Database Viewer. Select Window>>Refresh to verify that the tables were created successfully.
Reader Comments | Submit a comment »
Updates to document
Step 13 in the "Creating the Database
and User" section needs to be changed.
It states ". The step says to click
on ">>", but this needs to be changed
to "<<".
The "ODBC Data Source Administrator"
The image "67eefe69525.gif" or the
MYSQL Connector/ODBC screen shot
should be changed to refelct the
database given in the setup. Also
server should be left blank (blank
means to default to localhost).
In the "Creating Database Tables"
section step 3 should read "Select
File>>New Execute SQL Window..."
Just my two cents worth.
- Chad Powell, DAQTron. cpowell@daqtron.com - Aug 23, 2007
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
