Two Plus Two Newer Archives

Two Plus Two Newer Archives (http://archives1.twoplustwo.com/index.php)
-   Software (http://archives1.twoplustwo.com/forumdisplay.php?f=47)
-   -   Running Postgres from an AHK script -- Help? (http://archives1.twoplustwo.com/showthread.php?t=402461)

MSPChris 05-13-2007 11:02 PM

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??

_dave_ 05-13-2007 11:10 PM

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.

Thek 11-28-2007 05:54 PM

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

_dave_ 11-28-2007 06:00 PM

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.

Thek 11-28-2007 06:04 PM

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])

_dave_ 11-28-2007 06:09 PM

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?

Thek 11-28-2007 06:15 PM

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)

_dave_ 11-28-2007 06:19 PM

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...

Thek 11-28-2007 06:24 PM

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

_dave_ 11-28-2007 06:31 PM

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?


All times are GMT -4. The time now is 08:58 PM.

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