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 05-13-2007, 11:02 PM
MSPChris MSPChris is offline
Member
 
Join Date: Mar 2005
Posts: 70
Default Running Postgres from an AHK script -- Help?

Can someone point me toward some references on running PG queries from within an AHK script?

I know I've seen it either here or on overcards...but I've searched for about 1/2 hour... help??
Reply With Quote
  #2  
Old 05-13-2007, 11:10 PM
_dave_ _dave_ is offline
Senior Member
 
Join Date: Feb 2005
Location: UK
Posts: 2,628
Default Re: Running Postgres from an AHK script -- Help?

right at the bottom of the overcards.com AHK page:

http://www.overcards.com/wiki/moin.c...tgresFunctions

My Postgres include function.

you need to make sure to either have "Program files\postgresql\8.x\bin in your PATH environment variable, or (easier) copy "psql.exe" into your script's folder.

Post here if you have trouble with it - there are a few examples of use in the StarsBuddyList script, and in a few others.

dave.
Reply With Quote
  #3  
Old 11-28-2007, 05:54 PM
Thek Thek is offline
Senior Member
 
Join Date: Sep 2003
Location: In position
Posts: 115
Default Re: Running Postgres from an AHK script -- Help?

Hi Dave

Im trying to run your postgres_test AHK script, but can't seem to get it working.

PATH etc. is in order.

I keep getting 3 error files:
20071128225001_postgres_test.ahk_9469_error (0 kb)
20071128225001_postgres_test.ahk_9469_out (0 kb)
20071128225001_postgres_test.ahk_9469_in (1 kb)

The last file says:

\f '\t'
SELECT screen_name, COUNT(g.player_id) AS hands, round(AVG(vol_put_money_in_pot)*100,2) AS vpip, round(AVG(pre_flop_raise_n)*100,2) AS pfr FROM players p, game_players g WHERE p.player_id = g.player_id GROUP BY screen_name ORDER BY hands DESC LIMIT 10;
\q


Any ideas on what Im doing wrong?

Thanks
Reply With Quote
  #4  
Old 11-28-2007, 06:00 PM
_dave_ _dave_ is offline
Senior Member
 
Join Date: Feb 2005
Location: UK
Posts: 2,628
Default Re: Running Postgres from an AHK script -- Help?

Does it pop up any message?

If there is a problem there should be something in the "error" file.

Have you copied psql.exe to the same folder as the script?

Also, this query may take a little while to run.
Reply With Quote
  #5  
Old 11-28-2007, 06:04 PM
Thek Thek is offline
Senior Member
 
Join Date: Sep 2003
Location: In position
Posts: 115
Default Re: Running Postgres from an AHK script -- Help?

Hi Dave

No, no popup at all.

Yes, both the psql.exe is in the same folder (and in the PATH enviroment)

Been more than 1½ hour now (with only 4000 HH in DB [img]/images/graemlins/blush.gif[/img])
Reply With Quote
  #6  
Old 11-28-2007, 06:09 PM
_dave_ _dave_ is offline
Senior Member
 
Join Date: Feb 2005
Location: UK
Posts: 2,628
Default Re: Running Postgres from an AHK script -- Help?

no way it should take that long... are you on vista?

EDIT: or is postgres on a port other than 5432?
Reply With Quote
  #7  
Old 11-28-2007, 06:15 PM
Thek Thek is offline
Senior Member
 
Join Date: Sep 2003
Location: In position
Posts: 115
Default Re: Running Postgres from an AHK script -- Help?

On XP

Nope, is on port 5432 (also server is localhost, username is postgres and DB name is PTPGSQL1 in PT)
Reply With Quote
  #8  
Old 11-28-2007, 06:19 PM
_dave_ _dave_ is offline
Senior Member
 
Join Date: Feb 2005
Location: UK
Posts: 2,628
Default Re: Running Postgres from an AHK script -- Help?

OK, your best bet to figure out the problem is to edit the potgres_functions.ahk file.

Scroll down until you see the line:

<font class="small">Code:</font><hr /><pre>
RunWait, %comspec% /c %command%, , Hide
</pre><hr />

and remove the "Hide" from the end, leaving you with

<font class="small">Code:</font><hr /><pre>
RunWait, %comspec% /c %command%
</pre><hr />

EDIT: Then save, and run test.ahk again.

Doing this you should get the psql dosbox while the command is running... it hopefully gives a clue.

If it has run successfully, those three txt files should be deleted - so it is obviously getting stuck somewhere...
Reply With Quote
  #9  
Old 11-28-2007, 06:24 PM
Thek Thek is offline
Senior Member
 
Join Date: Sep 2003
Location: In position
Posts: 115
Default Re: Running Postgres from an AHK script -- Help?

Bingo.

I got promtet for the postgreSQL password and after I typed it in the popup box came with the data. (and the files got deleted correctly)

In the potgres_functions.ahk file I can't see where to set the default value for the password. Is that correct?

Thanks, Dave
Reply With Quote
  #10  
Old 11-28-2007, 06:31 PM
_dave_ _dave_ is offline
Senior Member
 
Join Date: Feb 2005
Location: UK
Posts: 2,628
Default Re: Running Postgres from an AHK script -- Help?

excellect [img]/images/graemlins/smile.gif[/img]

Actually, I don't think you can set the password in the script [img]/images/graemlins/frown.gif[/img] I didn't make provisions for it, because a) usually the "postgres" user doesn't need one - and b) it is not advised by the postgres documentation.

I think the recommended method is to use a PG_PASS environment variable... wait one sec. while I dig up the link...

EDIT: PG_PASS is wrong (or for unix) I think. Windows wants a pgpass.conf file created somewhere... but I never did that.

All I did was to edit the pg_hba.conf file, and change the access mode for localhost connections from md5 to trust - this cuts the need for a password. Maybe not the most secure method... but if they can access localhost they can find pgpass.conf, right?
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 06:13 AM.


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