Sign in to follow this  
Followers 0
Wanja

Postgresql HOWTO ?

10 posts in this topic

#1 ·  Posted (edited)

Well I'm messing around with postgresql

so I tried some examples from the forum but I just get errors ^^

@error=2 - ODBC driver not installed

I'm using this example:

$oConn = _SQLConnect($sServer, $sDatabase, $fAuthMode = 0, $sUsername = "", $sPassword = "", $sDriver = "{SQL Server}")

So where do I get the odbc driver for postgresql?

And what do I insert here: {SQL Server} ??

anyone got an example for postgresql???

thx in advance ^^

Wanja

Edited by Wanja

Share this post


Link to post
Share on other sites



Well a google for "postgresql odbc drive" turned up 1,190,000 hits like this one: psqlODBC Downloads.

Run the odbcad32.exe utility and look at the 'Drivers' tabe, you'll see the list of driver names. Once you download and install it, your postgre ODBC driver will be listed there too.

:whistle:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Well a google for "postgresql odbc drive" turned up 1,190,000 hits like this one: psqlODBC Downloads.

Run the odbcad32.exe utility and look at the 'Drivers' tabe, you'll see the list of driver names. Once you download and install it, your postgre ODBC driver will be listed there too.

:whistle:

ok I installed psqlodbc.msi

so what to do next?

$sDriver = "{????}"

Share this post


Link to post
Share on other sites

ok I installed psqlodbc.msi

so what to do next?

$sDriver = "{????}"

Look in the ODBC utility again, at the Drivers tab. You should now have drivers for:

PostgreSQL ANSI

PostgreSQL Unicode

Use whichever is appropriate for you.

:whistle:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Look in the ODBC utility again, at the Drivers tab. You should now have drivers for:

PostgreSQL ANSI

PostgreSQL Unicode

Use whichever is appropriate for you.

:whistle:

How do I "use" it?

Share this post


Link to post
Share on other sites

How do I "use" it?

Your original question was:

$oConn = _SQLConnect($sServer, $sDatabase, $fAuthMode = 0, $sUsername = "", $sPassword = "", $sDriver = "{SQL Server}")

So where do I get the odbc driver for postgresql?

And what do I insert here: {SQL Server} ??

You have the driver and installed it (if you see it on the drivers tab of the ODBC utility), and that would make your command:

$oConn = _SQLConnect($sServer, $sDatabase, $fAuthMode = 0, $sUsername = "", $sPassword = "", $sDriver = "PostgreSQL ANSI")

...or "PostgreSQL Unicode" if that's what you need.

:whistle:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Your original question was:

You have the driver and installed it (if you see it on the drivers tab of the ODBC utility), and that would make your command:

$oConn = _SQLConnect($sServer, $sDatabase, $fAuthMode = 0, $sUsername = "", $sPassword = "", $sDriver = "PostgreSQL ANSI")

...or "PostgreSQL Unicode" if that's what you need.

:whistle:

Great!!! this works ... stupid me XD

but I have a final problem

this works:

_SQLQuery($oConn, "INSERT INTO myDB VALUES ('bla','lala', 'hoho')")

but how do I get some data out? I tried this:

$result = _SQLQuery($oConn, "Select * from myBD")

MsgBox(0,"Result",$result)

I only get get blanck msgbox T.T

Share this post


Link to post
Share on other sites

Great!!! this works ... stupid me XD

but I have a final problem

this works:

_SQLQuery($oConn, "INSERT INTO myDB VALUES ('bla','lala', 'hoho')")

but how do I get some data out? I tried this:

$result = _SQLQuery($oConn, "Select * from myBD")

MsgBox(0,"Result",$result)

I only get get blanck msgbox T.T

I am learning the SQLite UDF myself right now, and I don't know the UDF you are using. Are you sure the return value from _SQLQuery() is the results of the query? In SQLite, you get back a handle to the query and use further commands like _SQLite_FetchData() to get the returned data one row at a time.

In addition, the return data is usually in some kind of array, so you might try _ArrayDisplay() instead of a MsgBox().

:whistle:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I am learning the SQLite UDF myself right now, and I don't know the UDF you are using. Are you sure the return value from _SQLQuery() is the results of the query? In SQLite, you get back a handle to the query and use further commands like _SQLite_FetchData() to get the returned data one row at a time.

In addition, the return data is usually in some kind of array, so you might try _ArrayDisplay() instead of a MsgBox().

:whistle:

OK I tried

_ArrayDisplay(_SQLQuery($oConn, "Select * from mmopager"))

if @error then MsgBox(0,"Result",@error)

and I got "1" so no array?

do you know if there is any documentation for this stuff?

Edited by Wanja

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I GOT IT FINALLY XXXXDDDDD

$oConn = _SQLConnect("localhost", "myDB", 1, "myUser", "myPass", "{PostgreSQL ANSI}")

$adors = ObjCreate( "ADODB.RecordSet" )

$adors.Open( "SELECT * FROM myDB", $oConn )

While not $adors.EOF

MsgBox(0, "Result", "Name = " & $adors.Fields("name").Value )

$adors.MoveNext

WEnd

WOOOOOOOOOHOOOOOOOOOOOOOOOOOOOOOOOOOOOO XD

BIG THX 4 YOUR HELP PsaltyDS :whistle:

Edited by Wanja

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  
Followers 0