Don't know if this will help, but I just completed a beta script to query a PostgreSQL database.
Hope this helps. (Script not tested).
Code:
; Thanks to _dave_ on 2p2 forums
#SingleInstance Force
#Persistent
#NoEnv
SQLsince := "00:00:00 01/01/09"
ScreenName := "Bob"
;modify below for sql query statement
sql := "select count(playerhandscashkeycolumns_hero.netamountwon)
, sum(playerhandscashkeycolumns_hero.netamountwon) from players
, playerhandscashkeycolumns_hero where (players.playername = '" . ScreenName . "')
and (playerhandscashkeycolumns_hero.handtimestamp > '" . SQLsince . "');"
HandData := psql(sql)
msgbox, %HandData%
Return
#Esc::
ExitApp
psql(sql="", database="", debug=0, host="", username="")
{
; set default values below if you want to use different all the time
if (database = "")
{
database := "postgres"
}
if (host = "")
{
host := "localhost"
}
if (username = "")
{
username := "postgres"
}
; END default value section
; Delete previous files from previous execution if it still exists
FileDelete, SQLinputFile.txt
FileDelete, SQLoutputFile.txt
FileDelete, SQLerrorFile.txt
; Create psql query statement file
FileAppend, \f '\t'`n, SQLinputFile.txt ; changes field separator to tab character ('\t')
FileAppend, %sql%`n, SQLinputFile.txt ; add sql query statement
FileAppend, \q`n, SQLinputFile.txt ; quit psql
; Create psql input parameter string
; -A :unalign (uncenter) output columns
; -t : remove headers & footers
; -d : specify which postgreSQL database (Holdem Manager Database) to use
; -f : name of file contaning psql commands to process
; -0 : nmae of psql output file
; -2>: direct any errors to this file
command := "psql.exe -A -t -d " . database . " -f SQLinputFile.txt -o SQLoutputFile.txt 2> SQLerrorFile.txt"
RunWait, %comspec% /c %command% , , Hide
FileGetSize, errorsize, SQLerrorFile.txt
If (errorsize > 0)
{
FileRead, errortext, SQLerrorFile.txt
FileDelete, SQLinputFile
FileDelete, SQLoutputFile
FileDelete, SQLerrorFile
if (debug)
{
Msgbox, %errorcause%`n`n`n%errortext%
ExitApp
}
else
{
FileAppend, %A_Now% - An Error Occured:`n`nInput:`n%errorcause%`n`nOutput:`n%errortext%`n`n`n`n, %A_Scriptname%_Error_Log.txt
}
}
FileRead, sqlout, SQLoutputFile.txt ; load output into sqlout variable
; delete files
FileDelete, SQLinputFile.txt
FileDelete, SQLoutputFile.txt
FileDelete, SQLerrorFile.txt
StringTrimRight, sqlout, sqlout, 2 ; remove line feed from output
return %sqlout% ; return data