[PD-dev] Connecting up an SQL Database to PD

Hans-Christoph Steiner hans at eds.org
Tue Nov 6 19:17:13 CET 2007


On Nov 6, 2007, at 5:40 AM, Jamie Bullock wrote:

>
> On Mon, 2007-11-05 at 22:08 -0500, Hans-Christoph Steiner wrote:
>> I think it would be really nice to have a Pd-ish interface to MySQL,
>> I am glad you are taking this project on.  Here are some thoughts:
>>
>> - As for the objects, I think one idea is to have one object that is
>> the connection to the database, then everything gets sent thru that.
>> Then you can have supporting objects that help build queries, etc.
>> which are then fed to the connection object.  The results will come
>> out of the outlet of the connection object, and there again can be
>> objects to parse the results, if need be.
>
> I agree that this is the right architecture. WRT the 'connection
> handler' object, I had an idea that wrapping one of the database
> abstraction libraries might be the way to go. Perhaps libdbi
> (http://libdbi.sourceforge.net/).
>
>> - I think in order to make it work well, you are going to need to use
>> a thread so that Pd doesn't hang waiting for a response from the
>> database.  That means the interface needs to represent that the
>> object is not deterministic.  That could be a bit tricky.  For
>> example, you send a command to [mysql], then send another request
>> before the first one is finished, then you get a response.  How do
>> you know which request that response belongs to?  Normally this isn't
>> a problem in Pd since basically everything responds within its time
>> slice, so it acts as if everything is instantaneous.
>
> I don't understand what you mean here. Why would using threading stop
> the object from being deterministic? Surely you would have one thread
> for the database connection, and get results back in the order in that
> the queries were sent in. Or were you thinking of having a  
> multithreaded
> object with one connection per thread?

Pre-emptive threads are by their very nature non-deterministic  
because there is no way to guarantee that the things in different  
threads will execute with the same order everytime.  Yes, the order  
that you send the messages won't change if you have one thread for  
the message sending, but once you have the thread, you can't  
guarantee that the database will return it's answer within on logical  
Pd clock tick.  Pd/Max is built around this idea, that each object  
does it's thing within one clock tick.

.hc


------------------------------------------------------------------------ 
----

All mankind is of one author, and is one volume; when one man dies,  
one chapter is not torn out of the book, but translated into a better  
language; and every chapter must be so translated.... -John Donne






More information about the Pd-dev mailing list