PostgreSQL connectivity

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

PostgreSQL connectivity

Nils Kassube
Guten Abend.

What's the state of the art in connecting Dolphin to a PostgreSQL
database running on the same Win32 box (using the cygwin port) or on a
Linux server?

Do I have to use ODBC? I'm looking for something like this:

http://wiki.cs.uiuc.edu/VisualWorks/The+PostgreSQL+Library

Googling around, I've seen a link to

http://www.geocities.com/SiliconValley/Software/8887/PostgreSQL_Connection.zip

but this yields a 404.

Cheers,
Nils
--
Lübeck, Germany -- The Marzipan City
http://www.luebeck.de


Reply | Threaded
Open this post in threaded view
|

Re: PostgreSQL connectivity

Bill Schwab
Nils,

The main Squeak Swiki might point to some things that you could port to
Dolphin.  However, I'd encourage you to also consider MySQL.  If you are
concerned about some of the missing features, the development version might
help.  I've been using the stable version with ODBC and while it's early
days yet, I've been very impressed.  If you want to avoid ODBC, have a look
at:

   http://minnow.cc.gatech.edu/squeak/1972
   http://jdmsoft.com/MysqlDriver.html


Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: PostgreSQL connectivity

Barry Carr-5
In reply to this post by Nils Kassube
Nils Kassube <[hidden email]> wrote in
news:[hidden email]:

> Guten Abend.
>
> What's the state of the art in connecting Dolphin to a PostgreSQL
> database running on the same Win32 box (using the cygwin port) or on a
> Linux server?
>
> Do I have to use ODBC? I'm looking for something like this:
>
> http://wiki.cs.uiuc.edu/VisualWorks/The+PostgreSQL+Library
>
> Googling around, I've seen a link to
>
> http://www.geocities.com/SiliconValley/Software/8887/PostgreSQL_Connect
> ion.zip
>
> but this yields a 404.
>
> Cheers,
> Nils
> --
> Lübeck, Germany -- The Marzipan City
> http://www.luebeck.de 

Hi Nils,

May I also suggest that you check out FireBird (www.ibphoenix.com) this is
an open source port of Borlands Interbase Database Server.
Firebird/Interbase is a small v. fast database that requires little or no
attention from a dba,  it designed to be embedded into other applications
and to be "transparent" to the end-user. It is full featured, i.e. has:
Multi-Threaded architecture, Transaction control, triggers and stored
procedures and runs many platforms. There is an open-source odbc driver
which you can download from the ibphoenix site as well as OLE/DB driver(s)
for it which you can find on the contributors page. There are also free
front end administration tools. I've been using interbase for some years
now and have absolutely no complaints whatsoever.

I know this plug isn't what you originally asked about but I hope it helps.

Cheers

Barry Carr
Ixian Software Components Ltd
Blairgowrie
Perthshire
Scotland


Reply | Threaded
Open this post in threaded view
|

Re: PostgreSQL connectivity

L. M. Rappaport
On Sun, 6 Oct 2002 10:16:42 +0000 (UTC), Barry Carr
<[hidden email]> wrote (with possible editing):

>Hi Nils,
>
>May I also suggest that you check out FireBird (www.ibphoenix.com) this is
>an open source port of Borlands Interbase Database Server.
>Firebird/Interbase is a small v. fast database that requires little or no
>attention from a dba,  it designed to be embedded into other applications
>and to be "transparent" to the end-user. It is full featured, i.e. has:
>Multi-Threaded architecture, Transaction control, triggers and stored
>procedures and runs many platforms. There is an open-source odbc driver
>which you can download from the ibphoenix site as well as OLE/DB driver(s)
>for it which you can find on the contributors page. There are also free
>front end administration tools. I've been using interbase for some years
>now and have absolutely no complaints whatsoever.
>
>I know this plug isn't what you originally asked about but I hope it helps.
>
>Cheers
>
>Barry Carr
>Ixian Software Components Ltd
>Blairgowrie
>Perthshire
>Scotland

Barry,

        I take it then that you have used it with Dolphin?  By any
chance is there a native support package for Dolphin or are you using
it with ODBC.  I only ask as I didn't see any.  If you're using an OLE
driver, how would you compare it with ODBC?  (assuming you've done
such).

        Thanks,

--
Larry
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: PostgreSQL connectivity

Barry Carr-4
Hi Larry,

Sorry if I mis-represented myself. I have only ever used Firebird with
Delphi and C++ Builder (I predominately use Delphi, although I would like
make it 50/50 with Dolphin). These two development tools have components
that connect directly to Interbase/Firebird (IBObjects and Borlands
dbExpress/DataSnap components) and is blindingly fast.

I'm relatively inexprienced with Smalltalk and db connectivity was one of
the next things I was going to look at. I was going to go down the ADO
route as I believe that Dolphin supports this directly (is this
correct?), plus I've used ADO with Delphi.

There would be nothing to stop a developer writing a direct connection
package for Dolphin like those mentioned above (esp if they had a copy of
Delphi Professional or above as most of the source for the components is
shipped with the product - that should help in porting I would have
thought), however I don't know of such a package and until I read your
post it never occured to me to write one, might be while before I get
round to it unfortunately.

Cheers

Barry

L. M. Rappaport <[hidden email]> wrote in
news:[hidden email]:

> On Sun, 6 Oct 2002 10:16:42 +0000 (UTC), Barry Carr
> <[hidden email]> wrote (with possible editing):
>
>>Hi Nils,
>>
>>May I also suggest that you check out FireBird (www.ibphoenix.com)
>>this is an open source port of Borlands Interbase Database Server.
>>Firebird/Interbase is a small v. fast database that requires little or
>>no attention from a dba,  it designed to be embedded into other
>>applications and to be "transparent" to the end-user. It is full
>>featured, i.e. has: Multi-Threaded architecture, Transaction control,
>>triggers and stored procedures and runs many platforms. There is an
>>open-source odbc driver which you can download from the ibphoenix site
>>as well as OLE/DB driver(s) for it which you can find on the
>>contributors page. There are also free front end administration tools.
>>I've been using interbase for some years now and have absolutely no
>>complaints whatsoever.
>>
>>I know this plug isn't what you originally asked about but I hope it
>>helps.
>>
>>Cheers
>>
>>Barry Carr
>>Ixian Software Components Ltd
>>Blairgowrie
>>Perthshire
>>Scotland
>
> Barry,
>
>      I take it then that you have used it with Dolphin?  By any
> chance is there a native support package for Dolphin or are you using
> it with ODBC.  I only ask as I didn't see any.  If you're using an OLE
> driver, how would you compare it with ODBC?  (assuming you've done
> such).
>
>      Thanks,
>
> --
> Larry
> [hidden email]
>
>


Reply | Threaded
Open this post in threaded view
|

Re: PostgreSQL connectivity

David Gorisek-5
In reply to this post by Nils Kassube
For VisualWorks there already is a complete PostgreSQL connectivity package
which is working directly with PSQL using sockets only.

With the Source Tracking System, which I am selling, you can import
VisualWorks parcels directly into Dolphin Smalltalk where they can be loaded
as packages (source code only - this is also possible for VAST
applications).

I have done this in the past already and I think I have also published it
here but I can not find it anymore. Let me know if you - or anyone - are
still interested into this.

Best regards,

David Gorisek
http://www.gorisek.com


"Nils Kassube" <[hidden email]> wrote in message
news:[hidden email]...

> Guten Abend.
>
> What's the state of the art in connecting Dolphin to a PostgreSQL
> database running on the same Win32 box (using the cygwin port) or on a
> Linux server?
>
> Do I have to use ODBC? I'm looking for something like this:
>
> http://wiki.cs.uiuc.edu/VisualWorks/The+PostgreSQL+Library
>
> Googling around, I've seen a link to
>
>
http://www.geocities.com/SiliconValley/Software/8887/PostgreSQL_Connection.z
ip
>
> but this yields a 404.
>
> Cheers,
> Nils
> --
> Lübeck, Germany -- The Marzipan City
> http://www.luebeck.de


Reply | Threaded
Open this post in threaded view
|

Re: PostgreSQL connectivity

Nils Kassube
"David Gorisek" <[hidden email]> writes:

> With the Source Tracking System, which I am selling, you can import
> VisualWorks parcels directly into Dolphin Smalltalk where they can
> be loaded as packages (source code only - this is also possible for
> VAST applications).

I'm new to Smalltalk, so I'm not sure that I understand what you
mean. How much work is it to port Smalltalk code like the
mentioned PostgreSQL interface from VW to Dolphin?

I'm really surprised to see that the user base of Dolphin seems to be
so small that no one else has done this before.

> I have done this in the past already and I think I have also
> published it here but I can not find it anymore. Let me know if you
> - or anyone - are still interested into this.

Yes, I'm interested.

Cheers,
Nils


Reply | Threaded
Open this post in threaded view
|

Re: PostgreSQL connectivity

Blair McGlashan
"Nils Kassube" <[hidden email]> wrote in message
news:[hidden email]...

> "David Gorisek" <[hidden email]> writes:
>
> > With the Source Tracking System, which I am selling, you can import
> > VisualWorks parcels directly into Dolphin Smalltalk where they can
> > be loaded as packages (source code only - this is also possible for
> > VAST applications).
>
> I'm new to Smalltalk, so I'm not sure that I understand what you
> mean. How much work is it to port Smalltalk code like the
> mentioned PostgreSQL interface from VW to Dolphin?
>
> I'm really surprised to see that the user base of Dolphin seems to be
> so small that no one else has done this before.

That's one conclusion deftly jumped to. Here's another: Dolphin is a Windows
Smalltalk, and PostgreSQL isn't most peoples' first choice on that platform
(regardless of its merits).

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Re: PostgreSQL connectivity

David Gorisek-5
In reply to this post by Nils Kassube
Nils,

usually code using sockets only can be ported between dialects without
problems. The only problem are usually the GUI classes or OS specifics.
Everything else is easily portable as long as you follow some rules that you
get with experience.

Ok, I have taken the Store parcel from VW 5i.4, imported it into the STS
repository (STS stands for the Source Tracking System, see
http://www.gorisek.com). Then I have loaded it into the image. The STS
always tries to load as much as it can i.e. everything that compiles. After
loading the VW parcel into Dolphin I had the following messages in
Transcript window:

Loading in package PostgreSQLDriver VW 5i.4 from repository
Error: ErrorResponseMessage>>resultFor: at line 14: undeclared 'StreamError'
Error: PostgreSQLConnection>>externalConnection at line 8: undeclared
'SocketAccessor'
Error: PostgreSQLConnection>>externalConnection at line 8: expecting ']'
Error: PostgreSQLTest class>>test07 at line 14: undeclared
'Base64EncodingWriteStream'


You can see that there are only 4 methods that didn't compile. From the last
error I can see that you also need parcel Base64Encoding which will load
just fine with no changes at all.

After loading the package Base64Encoding the #test07 method can be loaded.
This code is not really needed but it is here to make a port complete.

So that leaves only two real methods that need to be changed for Dolphin.
The first one is:

---
resultFor: aQueryResult
 "^a Message
 The key result of my arrival is that an exception is thrown. Bifore
 throwing the exception I try and read the next ready for query
 message to clear the inbound message stream. If I get an
 StreamError exception trying to read the next message I just ignore
 it - the connection is probably broken because of the exception I
 represent."

 | nextMessage |

 [nextMessage := aQueryResult readStream next.
 nextMessage isReadyForQuery ifFalse: [PostgreSQLUnexpectedMessage raise]]
  on: StreamError do: [:exception | ].
 PostgreSQLErrorResponse raiseSignal: errorMessage.
 ^nextMessage resultFor: aQueryResult
---

Here class StreamError does not exist in Dolphin. Ok, we'll just use
SocketError which should do the same thing.

The second method that needs to be changed is:
---
externalConnection
 "^an  ExternalConnection
 I return an external connection.  This represents the connection to the
back end, and makes two streams available, one for reading from the back
end, and one for writing to the back end.  Both streams are set to operate
in binary mode"

 externalConnection isNil
  ifTrue:
   [| socket |
   socket := SocketAccessor newTCPclientToHost: self parameters host
      port: self parameters port.
   externalConnection := ExternalConnection ioAccessor: socket].
 ^externalConnection
---

I've changed this one to:

---
externalConnection
 "^an  ExternalConnection
 I return an external connection.  This represents the connection to the
back end, and makes two streams available, one for reading from the back
end, and one for writing to the back end.  Both streams are set to operate
in binary mode"

 externalConnection isNil
  ifTrue: [| host address |
   host := parameters host.
   (host notEmpty and: [host first isDigit])
    ifTrue: [address := InternetAddress fromIPString: host]
    ifFalse: [address := InternetAddress host: host].
   externalConnection := Socket port: self parameters port address:
address ].
 ^externalConnection
---

Now I also had to change the #isActive method to:
---
isActive
 "^a Boolean
 I return true if I'm. I know this because a) I have an
 underlying connection, and b) it's active."

 ^self externalConnection isOpen
---

...and that's all I did. The code is available here:

http://www.gorisek.com/homepage/PSQLConnect.zip

Here you will find a Dolphin package for native PSQL connectivity. Hope it
works, at the moment I don't have a Linux machine near me to be able to test
it.

Best regards,

David Gorisek
http://www.gorisek.com



"Nils Kassube" <[hidden email]> wrote in message
news:[hidden email]...

> "David Gorisek" <[hidden email]> writes:
>
> > With the Source Tracking System, which I am selling, you can import
> > VisualWorks parcels directly into Dolphin Smalltalk where they can
> > be loaded as packages (source code only - this is also possible for
> > VAST applications).
>
> I'm new to Smalltalk, so I'm not sure that I understand what you
> mean. How much work is it to port Smalltalk code like the
> mentioned PostgreSQL interface from VW to Dolphin?
>
> I'm really surprised to see that the user base of Dolphin seems to be
> so small that no one else has done this before.
>
> > I have done this in the past already and I think I have also
> > published it here but I can not find it anymore. Let me know if you
> > - or anyone - are still interested into this.
>
> Yes, I'm interested.
>
> Cheers,
> Nils