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

Jamie Bullock jamie at postlude.co.uk
Tue Nov 6 11:40:24 CET 2007


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?

Jamie

-- 
www.postlude.co.uk





More information about the Pd-dev mailing list