|
#1
|
|||
|
|||
NEW AHK Script:: PostgreSQL database #include function
Hi all,
I have posted an AHK function to connect to Postgres databases from AHK scripts on overcards.com here It could be used for custom HUD stats, for example. Or to feed data to a table selection utility. And probably much more, who knows.... Please feel free to use this for any scripts you may think useful, please share scripts in return [img]/images/graemlins/smile.gif[/img] Post any comments / questions in this thread, I will try and help. Hopefully this is of use to some, Enjoy, dave. |
#2
|
|||
|
|||
Re: NEW AHK Script:: PostgreSQL database #include function
Awesome
did you get my PM? |
#3
|
|||
|
|||
Re: NEW AHK Script:: PostgreSQL database #include function
Hi Dave
Thanks for the good work, just getting around to playing with this. So far I have ran into a problem. Here is my setup so you understand the arcitechture... Playing machine (XP with PT, PAHUD, AHK scripts, poker clients, 192.168.100.x). Server machine (FC5_64, PSQL 8.0, 192.168.100.90) The DB that I am testing with is named UB Here is my config in the function script... psql(sql="", database="UB", debug=1, host="192.168.100.90", username="pokertracker") When I run the functions script I get this error... [ QUOTE ] Error at line 77. Line Text: "UB" Error: Bad default value. Program will exit. [/ QUOTE ] If I execute the test script the error is the same except it references the include file. Also I use a password on my DB's, but I do not see anywhere in the code that a password is referenced. |
#4
|
|||
|
|||
Re: NEW AHK Script:: PostgreSQL database #include function
OK, I played with it a bit more...
I still can get the values to take in the psql defination line, but in the "error checking" code to set DB name, user, host, I can leave the psql fields empty and specify the DB, user, host in the checking for defaults and it works. Also I reread the notes and see that password checking is not supported from psql.exe, interesting... |
#5
|
|||
|
|||
Re: NEW AHK Script:: PostgreSQL database #include function
Hi Percula,
You are running in to one of the oddities of AHK, namely that when passing a string to a function, the only valid default is an empty string, "". This is the reason all the strings in the psql function call are set immediately (if empty) as soon as the function starts, e.g. there are several of these chunks, one for each default value: if ( host="" ) { host := "localhost" } it is these bits you change to set default values, not the empty strings in the function definition line, which must always remain "". -But I think you figurted this out already, from your above post. [ QUOTE ] Also I use a password on my DB's, but I do not see anywhere in the code that a password is referenced. [/ QUOTE ] [ QUOTE ] Also I reread the notes and see that password checking is not supported from psql.exe, interesting... [/ QUOTE ] This is a little complicated - It is not that psql.exe does not support password checking (it does), only that there is no simple way to provide the password on the command line. When using password authentication, the scripted psql will pause expecting the user to input the password, which of course does not happen since the program is running (hidden) via script. There are ways to use passwords with this script, but for the sake of simplicity I chose to use the "trust" (trusted hosts) method, since it is a) likely the script will only be used within one's own (trusted) network, b) a "sledgehammer" approach that removes all authentication problems, and c) I decided that in a situation that needs passwords enough that "trust" is unacceptable, it is probably not a great idea to have passwords stored in plain text AHK files [img]/images/graemlins/smile.gif[/img] see this page for some interesting tips and methods for how to feed a password to psql when used in a script. Also, [ QUOTE ] Here is my setup so you understand the arcitechture... Playing machine (XP with PT, PAHUD, AHK scripts, poker clients, 192.168.100.x). Server machine (FC5_64, PSQL 8.0, 192.168.100.90) [/ QUOTE ] It sounds like you got it working, so you will have this already sorted I think, so mainly for the benefit of others - With such a setup (remote linux PostgreSQL host, WinXP client), you need to have the Windows version PostgreSQL installed on the playing machine, so it can use the psql.exe command. Actually, it is probably enough just to copy psql.exe from the Windows distribution and have that in the XP $PATH - I think that it works stand alone. dave. |
#6
|
|||
|
|||
Re: NEW AHK Script:: PostgreSQL database #include function
[ QUOTE ]
It sounds like you got it working, so you will have this already sorted I think, so mainly for the benefit of others - With such a setup (remote linux PostgreSQL host, WinXP client), you need to have the Windows version PostgreSQL installed on the playing machine, so it can use the psql.exe command. Actually, it is probably enough just to copy psql.exe from the Windows distribution and have that in the XP $PATH - I think that it works stand alone. dave. [/ QUOTE ] OK, that makes more sense now. Thanks for taking the time to explian it. And yes, there is no need to install PSQL on the Win32 machine. You can download the binary only files from http://www.postgresql.org/ in a ZIP file and simply extract the psql.exe file and make sure you have a path to it. I used the 8.0.x version and it worked fine. Now to brush up on my VERY rusty SQL skills... [img]/images/graemlins/blush.gif[/img] |
#7
|
|||
|
|||
Re: NEW AHK Script:: PostgreSQL database #include function
Hey Dave,
I just saw this today. Very, very cool stuff! Adde |
#8
|
|||
|
|||
Re: NEW AHK Script:: PostgreSQL database #include function
i can see this being very useful. thank you.
|
|
|