Jump to content
Sign in to follow this  
BigyBG

Help for multiple read/write connections to PostgreSQL from AutoIT script.

Recommended Posts

BigyBG

Is it possible to run a multiple read/write connections to PostgreSQL from AutoIT script?

Thanks :oops:

Share this post


Link to post
Share on other sites
hannes08

If PostgreSQL support multiple read/writes it's surely possible.

Anyway it depends on what you make of it. :oops:


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites
BigyBG

This is my script.

$Conn = ObjCreate("ADODB.Connection")
$Record = ObjCreate("ADODB.Recordset")
$DataRecord = ObjCreate("ADODB.Recordset")

Func Create_Conn()
[indent=1]$strConn = "DSN=PostgreSQL32;DATABASE=MyDB DB;SERVER=localhost;Port=5432;Uid=postgres;Pwd=MyPass"[/indent]
[indent=1]$Conn.Open($strConn)[/indent]
[indent=1]If @error Then MsgBox(0,"","Error Opening Connection")[/indent]
EndFunc

Func Close_Conn()
[indent=1]$Conn.Close[/indent]
EndFunc

Func ID()
[indent=1]Local $Task,$strReturn[/indent]
[indent=1]$Task = "SELECT name,id FROM list WHERE name = '" & $Name  "';"[/indent]
[indent=1]$Record.open($Task,$Conn,1,3)[/indent]
[indent=1]If @error Then MsgBox(0,"","Error Executing SQL in: Func ID")[/indent]
[indent=1]$strReturn = $Record.recordcount[/indent]

[indent=1]If $strReturn > 0 Then[/indent]
[indent=2]$strReturn = $Record.GetRows()[/indent]
[indent=2]$ID = $strReturn[0][1][/indent]
[indent=2]MsgBox(0,"","Name: " & $strReturn[0][0] & " ID: " & $ID)[/indent]
[indent=1]EndIf[/indent]

[indent=1]$Record.close[/indent]
EndFunc

The skript is working, but the problem is that is very slow.

When I start querry in pqAdmin response time is 0.05 sec. But from my script is more that 30 sec. And I don't know how to improve. Any idea???

Thanks...

Edited by BigyBG

Share this post


Link to post
Share on other sites
BigyBG

Help, please.....

Share this post


Link to post
Share on other sites
JLogan3o13

BigyBG, please do not bump your posts in less than 24 hours. This gives us plenty of time to try to assist you.

Also, please place your code in AutoIt tags. This will make it much easier to read.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
jchd

About your initial question: all ADO/ODBC drivers I know off allow for unbounded number of simultaneous connections (up to available RAM and such).

As it is your script is certainly not "taking 30s" since it does nothing beyond declaring 3 objects and 3 functions (never invoked) and so would return almost instantly.

When you post your actual script of failing short reproducer, someone can eventually help.

Also something generic (valid for PostGres and almost any DB engine AFAIK): use available escape mecanism for escaping possible single quotes in the litteral values you feed (may depend on actual engine, but is commonly made by doubling inner quote(s)). In your example ID function, if $name contains a quote, the SQL gets invalid. If it doesn't it's open to SQL injection. Now where $name comes from is a mystery.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×