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

Jamie Bullock jamie at postlude.co.uk
Mon Nov 12 12:10:08 CET 2007


Hi Mike,

On Thu, 2007-11-08 at 12:52 -0600, Mike McGonagle wrote:

> I don't know if anyone would be interested in seeing the external that
> I have so far (while there are only a couple of files, it is kind of
> messy), but the file for SQLite is almost 2.5 megs, just by itself.
> Compressed, this whole thing is about 1.2 megs. The compiled external
> comes out to be able .5 megs. I am working on PPC 10.4.10 Mac, so
> anyone using that could probably use my compiled external. Anyone on
> other platforms will have to fend with my simple makefile.
> 
> You can get the files from ftp.wpco.com, with the user 'fsr', and the
> password of 'puredata'. There is a zip file with the external source,
> a makefile, a couple of preliminary examples. Try the 'test2' one, as
> it may be the most understandable. Also, as I said, this doesn't
> really do much more than spew to the console, but it is a start.
> 

I had a look at your external, and I have a few comments. Firstly I
think having a sqlite external for Pd is a nice idea because it is very
light weight. If you statically link to the sqlite3 library then nothing
is required but the external itself -- no database server to configure,
which is a big advantage. On this basis, I think an embedded sqlite will
always be welcome, and can happily coexist with other solutions e.g. the
sqlsingle/psql externals, and the lua and Python scripting solutions.

A few suggestions about the code/design:

1. I would strongly suggest not including the sqlite sources with the
sqlite4pd sources. I had a raft of build errors trying to work this way,
whereas downloading and building sqlite from the sources on sqlite.org
was a breeze.

2. I think having the SQL query provided as an object creation argument
is a really bad idea.  Wouldn't it be better to just pass the query in
as a list (see the psql sources in CVS for an example of how to do
this). You are also reinventing Pd's existing variable substitution with
your @ substitution.

3. Your test.pd file seemed to work, but when running example.pd, I get
'...got something very wrong...' posted to the Pd console, and Pd
crashes when I click the subpatches. Not sure why this is, but I
definitely suggest a more informative error message than 'got something
very wrong' ;-) 

4. It looks like your 'next' and 'dispose' methods aren't implemented
yet. Do you plan to cache the query results in the object's data struct
and then use 'next' to iterate over them? Why not just dump the results
to an outlet(s) (again see sqlsingle/psql code)? If you want to store
the results and then iterate over them, they can be dumped to a
[textfile] object.

Just a few thoughts.

Jamie

-- 
www.postlude.co.uk





More information about the Pd-dev mailing list