Two Plus Two Newer Archives  

Go Back   Two Plus Two Newer Archives > Internet Gambling > Software
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-12-2006, 10:00 PM
_dave_ _dave_ is offline
Senior Member
 
Join Date: Feb 2005
Location: UK
Posts: 2,628
Default 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.
Reply With Quote
  #2  
Old 10-13-2006, 12:03 AM
coxquinn coxquinn is offline
Senior Member
 
Join Date: Sep 2005
Location: Making Aggressive Calls
Posts: 1,012
Default Re: NEW AHK Script:: PostgreSQL database #include function

Awesome

did you get my PM?
Reply With Quote
  #3  
Old 10-15-2006, 05:47 PM
Percula Percula is offline
Senior Member
 
Join Date: Jun 2004
Location: Phoenix
Posts: 2,050
Default 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.
Reply With Quote
  #4  
Old 10-15-2006, 06:10 PM
Percula Percula is offline
Senior Member
 
Join Date: Jun 2004
Location: Phoenix
Posts: 2,050
Default 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...
Reply With Quote
  #5  
Old 10-15-2006, 07:25 PM
_dave_ _dave_ is offline
Senior Member
 
Join Date: Feb 2005
Location: UK
Posts: 2,628
Default 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.
Reply With Quote
  #6  
Old 10-15-2006, 10:34 PM
Percula Percula is offline
Senior Member
 
Join Date: Jun 2004
Location: Phoenix
Posts: 2,050
Default 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]
Reply With Quote
  #7  
Old 10-17-2006, 12:48 PM
Adde Adde is offline
Senior Member
 
Join Date: Oct 2002
Location: Sweden
Posts: 2,453
Default Re: NEW AHK Script:: PostgreSQL database #include function

Hey Dave,

I just saw this today. Very, very cool stuff!

Adde
Reply With Quote
  #8  
Old 10-21-2006, 12:03 AM
george w george w is offline
Senior Member
 
Join Date: Oct 2003
Location: austin, tx
Posts: 1,790
Default Re: NEW AHK Script:: PostgreSQL database #include function

i can see this being very useful. thank you.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:47 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.