Jump to content

Postgresql HOWTO ?


Recommended Posts

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
Link to comment
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
Link to comment
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 = "{????}"

Link to comment
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
Link to comment
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
Link to comment
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

Link to comment
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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...