SQL DB Connection String help

Thanks so much for all of the helpful information in the blog posts and documentation.
It got me up and running quickly with the QA401. I also was able to create a test plan in Tractor easily following the blog posts.

Where I am having trouble is data acquisition in an easy to view format. I can view the test data in the HTML format but I was really looking to use something like Excel or even a .csv export. That led me to look into the SQL path. I have never used SQL before but I am a quick study.

I have the database setup on my windows PC using MySQL and I am able to perform some basic functions. However, I am unable to figure out how to connect Tractor to my SQL database. I have been trying to use the DB Connect String but I must not be putting in the correct entries.

Is there any guidance you can provide for setting up the database connection for new users of SQL?

The cloud route you offer seems really great but I need longer-term storage and would also like to be able to manipulate the data and export from SQL to Excel to pass along to clients as needed.

Unless there is an easy way to get the test data in excel that I am missing.

Thanks so much for any help!

Josh Mc

Hi Josh,

I don’t think it will connect to MySql. But Microsoft’s SQL Server Express Edition is free. Basically, you install the express edition and then you install SQL server management studio. That is a UI front-end to connect to the database.

The default connection string in Tractor is

Server=MyPc\SQLEXPRESS;Integrated security = SSPI; Initial Catalog = QATestDB; User ID = sa; Password=password

This has some implications for how you set things up. The default server name is MyPc\SQLEXPRESS. This will need to change based on your machine name. For example, on my machine, when I open SQL management studio I see the following tree:

image

There I can see my machine name and the path to the server: “OFFICEPC-2012\SQLEXPRESS”

The Integrated Security = SSPI should stay. This means you want to connect to the server using Windows Authentication (your user name and password) rather than SQL authentication. You need to make sure SQL is using the same (that will be shown below).

The Initial Catalog means the database you wish to work with. This is a decision you make. You might prefer to have all products dump into one database, or you might prefer one database per product. For now, you can leave as default.

Finally, you have the user name and password. The ‘sa’ user account is the highest priority user–the system administrator. If you are using Management Studio to handle a lot of databases, then you don’t want this used for simply logging data from a single machine. But if you are just running SQL for the sole purpose of logging test data, then it’s fine to use if you change the password.

In Management Studio, to set the login type and the sa password, you right click on the server instance and pick the security tab. There you need to make sure it’s Windows Authentication

Then, work your way down to the security and logins tab and you’ll find the sa user. Right click and open those properties and you’ll be able to set the sa password.

Now, you could also set another user name and pass at this stage too. This is where you’d want to set things up so that different engineering teams might have access to different product databases.

Now you should be able to construct your actual connection string and put that into the Tractor settings:

Pressing the “Test Connection” button doesn’t mean you have the connection string correct. But it does mean that Tractor can talk to the database.

Next, push the Create Database button. Now, go back to SQL Management Studio, right click on your server and pick “refresh”

If your connection string is correct, you should see a database with the name used in the connection string appear:

image

If you push the Delete Database, Tractor will try to delete it, but that can only happen if it’s disconnected. Most likely it will fail. But you can right click on the database in Management Studio and pick “Delete” and Management Studio will let you force a disconnect and delete. And you can do the process again to help solidify how it works. Or create another database.

And once you have the data SQL, then you can export it in a CSV format if you wish, with lots of flexibility on how it’s formatted.

But I think you raise a good point that having a parallel log in CSV format (in addition to HTML) would be useful because the HTML can’t be readily parsed by machine.

@joshmc, looking at this more, if you would be able to test it out I think the CSV logging could be added easily–in a few hours. Take a read on the above, and if you think you only need to database stuff to eventually get a CSV then I think it would be better to just add a csv logging option because it is indeed hard to get the data out of a database if you don’t have a database guy.

Thank you so much for the thorough answer Matt!
CSV logging would be much more convenient and I would be happy to test it out.
It would be a much easier workflow and save me some headaches down the road.

Thanks!
Josh

Hi Josh, I just posted a new version of Tractor to the github link below. In the settings file, you’ll see the logging options are now arranged in tabs. The CSV tab lets you turn on/off CSV logging. You must specify a file name. From that point on, all tests for that test file will log to that CSV file. You can log to CSV, SQL database and/or Cloud Database.

Let me know if you see any issues.

Wow, that’s fantastic Matt! Thanks, I will check it out!
Josh

It looks like it will work perfectly for what I need!

A few questions:
Is the Test Group just a randomly generated GUID? And it only applies to one running of the test sequence for one unit. So the next unit test has a new GUID?

What is the TestFileMd5? I am assuming if I change any parameters of the test it creates a new TestFileMd5?

One thing I found, is that if you have the .csv file open and run a test (by accident) it will NOT throw a warning and it will:

  1. Not log the test in the .csv file
  2. It will also uncheck the “Use CSV log” box in the settings unknowingly and even if you close the .csv file it won’t .csv log until you go back and recheck the box.

I’m not sure that there is a solution for that except make sure you don’t open the .csv until you are done testing and if you do open it at any point it must be closed before running more tests.

Thanks so much for your help with this. It will be much easier for me to use the data from the tests with the .csv logging.

From a UI perspective if there was an option for a serial number prompt in the operator category it may be helpful to others setting up testing. I just did an operator prompt and put serial number in the prompt text and it did place it in the Serial Number column automatically. So even though Tractor read the text string and was able to determine it was a serial number it would be more straightforward to have it as a listed prompt option. Just was thinking.

Thanks again for all of the assistance! I’m really happy with the 401A and Tractor and the .csv logging will be so much easier for me and if I set any clients up with a 401A and Tractor for their production testing. It just hasn’t been something I’ve been able to do as the other available options were just too costly to justify for the DUT specifications I need for testing.

Josh

Hi @Josh,

Is the Test Group just a randomly generated GUID?

yes, the Test Group will allow you find all measurements that were made together. Usually this means there’s a left channel measurement and a right channel measurement. So, if you make a stereo THD measurement, they will share the same Test Group guid. In a CSV file, this is easy to see based on the order. But if you have a bunch of records in a database, it’s not clear unless you look at the time stamp, but even then the time between the left and right measurements would have a different time stamp since they are saved to the db at slightly different times (and you might have run a product several times with repair between each run).

What is the TestFileMd5?

Yes, TestFileMd5 is a fingerprint of the test file so that if you see a same product serial number with different measurements, you can know if it was the same test file or not.

One thing I found, is that if you have the .csv file open and run a test (by accident) it will NOT throw a warning

That is correct about no warning: In your settings file the Log to CSV will be turned off and testing will continue. That will happen anytime logging to CSV fails (disk full, can’t open file for writing). Some text editors (Notepad++) will open the csv file in read-only mode which means you can keep logging while you are looking at the file. And then when you switch back to the app they will ask if you want to re-load the file. Other editors (such as Notepad) will open the file in read/write mode, which means nobody can write to it. So, if you want to browse the CSV in real time, then pick an editor that gives the option to open the file in read-only mode.

In any case, if you look in the application log (see C:\Users\<USER>\Documents\QuantAsylum\Tractor\Tractor_Log.txt then you should see a note in there that CSV logging was disabled and the reason why. That log is re-started every time the app re-starts.

A case could be made that failure to open the log file to append a test means something really bad has happened and all tests should fail until the issue is fixed OR until logging is disabled. Would you prefer to have a log failure result in failing the current test and then nothing can run until you disable logging or fix the issue?

I just did an operator prompt and put serial number in the prompt text and it did place it in the Serial Number column automatically.

Operator Prompt doesn’t allow you enter anything, only IdInput. If you use that it will take that be a serial number always as long as the user has entered something. But they must enter something. If they don’t, then it will result in a fail.

It just hasn’t been something I’ve been able to do as the other available options were just too costly to justify for the DUT specifications I need for testing.

Thanks for your input on this! It was a for sure needed feature

Thanks for the clarification on the Test Group and TestFileMD5.

I would prefer an option to fail the test if it is unable to log. I’m not sure everyone would. Could it be a checkbox option in the settings?

I misused the word “prompt” as I did use IdInputA00. It was just a naming convention difference that I didn’t associate IdInput with the Serial Number column. It makes perfect sense, I just was looking for serial number input on the test setup as that is what the .csv column was named, lol.

Thanks for all your help! I’m using the QA401 daily since I received it as it’s a lifesaver for a current project.

Josh

Hi @Joshmc, after discussion it will be changed so that CSV log failure will result in operator message and test failure, and if bypass is needed then the CSV log option will need to be unchecked. Hopefully this will be in early next week. Thanks again for your well thought out points on this feature.