Export SQL Table as .CSV?

Hey guys, I’m a fairly new user of ignition, and I’m loving it so far. I’ve got a bit a of a problem that I’m not sure how to solve with jython:

I want to export an entire SQL table as a .CSV. Basically, I want to build a button in ignition that exports the results of the following query as a .CSV:

SELECT [Example_ndx] ,[Example1] ,[Example2] ,[Example3] ,[Example4] ,[t_stamp] FROM [Example_Process].[dbo].[Example]

I think I have to do it with system.dataset.exportCSV, but the only examples I’ve found are populating a table and pulling it from there.

Does anybody have a sample script I can look with an explanation of how it is accomplishing what I want?

I got it. In my case they actually wanted all of the columns, so this code worked:

[code]table = system.db.runQuery(“SELECT * FROM [Example].[dbo].[Example_Log]”)

filePath = system.dataset.exportCSV(“Example_Log.csv”, 1, table)

if filePath != None:

system.net.openURL("file:///"+filePath.replace('\\','/'))[/code]

I tried to attach a date to the filePath, but failed. I’ll call this one solved, but if y’all want to provide some help, that’d be great.