The connection string is probably the most vexing part of SQL. Fortunately, Google is your friend, you just need to search for "connection string" along with the brand name of your RDBMS.
Although not canon, this function accepts up to two additional options appended to the connection string. RowDelim and ColDelim will tell ADOSQL to return a delimited string instead of an object. This is demonstrated in the example below.
Download: AHK-Lib-ADOSQL.zip
Also on GitHub
Here's an example showing the use of microsoft's ODBC text driver with a csv file.
Code: Select all
SetWorkingDir, %A_ScriptDir%
IfNotExist, products.csv
FileAppend,
(
P_CODE,P_DESCRIPT,P_INDATE,P_QOH,P_MIN,P_PRICE,P_DISCOUNT,V_CODE
"11QER/31","Power painter,15 psi.,3-nozzle","03-NOV-2011",8,5,109.99,0.00,25595
"13-Q2/P2","7.25-in. pwr. saw blade","13-DEC-2011",32,15,14.99,0.05,21344
"14-Q1/L3","9.00-in. pwr. saw blade","13-NOV-2011",18,12,17.49,0.00,21344
"1546-QQ2","Hrd. cloth,1/4-in.,2x50","15-JAN-2012",15,8,39.95,0.00,23119
"1558-QW1","Hrd. cloth,1/2-in.,3x50","15-JAN-2012",23,5,43.99,0.00,23119
"2232/QTY","B\&D jigsaw,12-in. blade","30-DEC-2011",8,5,109.92,0.05,24288
"2232/QWE","B\&D jigsaw,8-in. blade","24-DEC-2011",6,5,99.87,0.05,24288
"2238/QPD","B\&D cordless drill,1/2-in.","20-JAN-2012",12,5,38.95,0.05,25595
"23109-HB","Claw hammer","20-JAN-2012",23,10,9.95,0.10,21225
"23114-AA","Sledge hammer,12 lb.","02-JAN-2012",8,5,14.40,0.05,NULL
"54778-2T","Rat-tail file,1/8-in. fine","15-DEC-2011",43,20,4.99,0.00,21344
"89-WRE-Q","Hicut chain saw,16 in.","07-FEB-2012",11,5,256.99,0.05,24288
"PVC23DRT","PVC pipe,3.5-in.,8-ft","20-FEB-2011",188,75,5.87,0.00,NULL
"SM-18277","1.25-in. metal screw,25","01-MAR-2012",172,75,6.99,0.00,21225
"SW-23116","2.5-in. wd. screw,50","24-FEB-2012",237,100,8.45,0.00,21231
"WR3/TT3","Steel matting,4""x8""x1/6",.5" mesh","17-JAN-2012",18,5,119.95,0.10,25595
), products.csv
; Connection strings are typically semicolon-separated lists of key/value pairs
connection_string =
( ltrim join;
Driver={Microsoft Text Driver (*.txt; *.csv)}
Extensions=asc,csv,tab,txt
Persist Security Info=False
)
; Here, the "coldelim" option is added on the fly to tell ADOSQL to return a string
MsgBox % ADOSQL( connection_string ";coldelim= `t", "
(
SELECT P_CODE, P_PRICE, P_DESCRIPT
FROM products.csv
WHERE P_PRICE > ( SELECT AVG( P_PRICE ) FROM products.csv )
)")
filedelete, products.csv