|
MySQL connection in Quartz ComposerI have a video playback system I implemented with max/msp/jitter that can uses either MySQLJDBC http://www.mdhosale.com/mysqljdbc/or Nick Rothwells net.loadbang-SQL http://www.loadbang.net/space/Software/net.loadbang-SQL to submit queries from max/msp I would like to rebuild this system with Quartz Composer andI have made some initial attempts using OSC to pass data between max/msp and QC but would prefer to only use QC if possible. I have searched various forums and google and have not found anything, so I am assuming that it is not possible, but wanted to ask here as I have limited knowledge of Javascript and MySQL. To summarise are there any documented patches that can query a MySQL database from QC using Javascript or is there an inherent limitation/restriction in Javascript or QC that makes this not possible? Thank you for reading.
|
Javascript in QC doesn't have any way to access MySQL (or ODBC/JDBC bindings), so that's out.
However, a custom patch could perform SQL queries. It hasn't been requested much (there's been some talk, but it's usually quickly abandoned in favor of something simpler), so that's probably why you haven't seen anything from it.
I would also be interested in a MySQL patch.
thank you for the information, I think I understand how this can be achieved.
the main part of this project was built around MySQL and the part I want to rebuild is a simple client, which is only required to query the database and playback the returned video file (filename).
I only need to need the custom patch to perform two functions; make a connection, and perform the query.
I am not a programmer but I will read through 'Introduction to Quartz Composer Custom Patch Programming Guide' when I next have time and try to work it out from there.
Thank you
A few years ago I worked with the MySQL C library. It is actually pretty straightforward. I don't think it would take very long to get a working QC patch, although I don't know if I have time in the immediate future.
Just curious, what kind of interface are you envisioning? The first one that popped in to my head was just a String input to the QC patch where you could put an SQL statement and an outlet that maps the rows returned to a Structure/array.
Update:
Here's a basic outline of it:
I might see if I can bang out a really quick version of it... I'll keep you posted.
Yikes, well upon further inspection I'm realizing all my MySQL C knowledge is based around Makefiles, so it's probably going to take me some tinkering to get it working with Xcode...
Hello William/
The interface I had in max/msp/jitter used a scheme tracked two badge colours (using the cv.jit externals from Jean-Marc Pelletier), when a badge colour is detected the patch would format a specific query associated with that badge.
The query would return .mov filename from the database (from a list of files associated with the profile for that badge), because the database is programmed using a weighting system based on profiles for each badge type, I cannot replicate the database with folders or xml, which is why I would like to find a QC based solution for connecting to MySQL
I have not looked in to handling the colour tracking in QC in detail but what I have seen suggests it is possible; the MySQL component would only need to be able to format and make a simple query when necessary.
I am also interested in a MySQL plugin, I would also pay for it, or if any develop is interested in a bounty system, I would be interested in supporting that as well.
Have you had any luck with this?
So, here's my first crack at it. It should be self-explanatory. BTW, I think it is compiled with a static library and should just work, but there's a chance that it might look for a dynamic library, which wouldn't work properly. Give it a shot, and let me know!
I'm gonna continue to work on it... there are quite possibly some memory leaks and other bugs, as with any first iteration.
Respond or email me at my_kineme_username@gmail.com with any bugs, suggestions, etc.
I think so, check out the post in below!
Is this for Snow Leopard or regular Leopard? I'm getting the following error in Console.app
9/24/09 4:56:19 PM Quartz Composer[2397] *** QCPlugIn: Cannot preflight plug-in at path "/Library/Graphics/Quartz Composer Plug-Ins/MySQLPatch.plugin" (Error Domain=NSCocoaErrorDomain Code=3585 UserInfo=0x11611c5f0 "The bundle “MySQLPatch” couldn’t be loaded because it doesn’t contain a version for the current architecture." (dlopen_preflight(/Library/Graphics/Quartz Composer Plug-Ins/MySQLPatch.plugin/Contents/MacOS/MySQLPatch): no suitable image found. Did find: /Library/Graphics/Quartz Composer Plug-Ins/MySQLPatch.plugin/Contents/MacOS/MySQLPatch: mach-o, but wrong architecture))
that post can also mean it's PPC or intel only -- filing it real quick, it looks like it's i386 only (32bit, intel).
that'll make Snow Leopard grumpy unless you start QC in 32bit mode
Hah, yeah, I'm still on Leopard. (I can't risk things not working right now :)
I didn't notice that it was a 32-bit only compile, try this one instead...
I just tried to do an x86_64 only compile and got a bunch of linker errors... I don't think my version of libmysqlclient is 64bit, which could be the issue...
Sorry, I'll see if I can figure something out!
That crossed my mind, but I totally forgot to try it until now :D
It does appear to be looking for that library:
9/24/09 6:06:07 PM Quartz Composer[6483] *** QCPlugIn: Cannot preflight plug-in at path "/Library/Graphics/Quartz Composer Plug-Ins/MySQLPatch.plugin" (Error Domain=NSCocoaErrorDomain Code=3587 UserInfo=0x19b6f4a0 "The bundle “MySQLPatch” couldn’t be loaded because it is damaged or missing necessary resources." (dlopen_preflight(/Library/Graphics/Quartz Composer Plug-Ins/MySQLPatch.plugin/Contents/MacOS/MySQLPatch): Library not loaded: /usr/local/mysql/lib/libmysqlclient.15.dylib Referenced from: /Library/Graphics/Quartz Composer Plug-Ins/MySQLPatch.plugin/Contents/MacOS/MySQLPatch Reason: image not found))
christopher, did you try running it in a 32bit environment? I'd like to make sure that it will indeed work on platforms without libmysqlclient available.
Ah nuts, ok, let me see if I can figure this out... UNLESS you want to just go and compile libmysqlclient... and I guess either make sure it ends up in the directory or at least create a link to it...
run "mysql_config" from the command line and look at the "--libs" option.
BTW, if anyone has any suggestions as to the better way to be doing this, let me know!
I might look in to a Cocoa MySQL framework...
If you want, you can grab the source and compile it yourself, once you've made sure you've got libmysqlclient...
http://github.com/williamcotton/MySQLPatch
Some tips:
Run mysql_config from the shell. Go in to the Project's build settings, and make sure that the output from mysql_config matches up with the following, as an example:
Typically, if you're using a Makefile, autoconf will run mysql_config and set up everything for you... honestly, I'm pretty new to Xcode, so there may very well be a better solution, for compiling with C libraries, I have no clue though.
I'm going to look in to getting a pre-compiled version working... any tips would be great!
I didn't try -- it's referencing a .dylib (DYnamic LIBrary), so I'm almost certain it's not staticly linked. In general, static linking is phenomenally rare on OS X
Darn GitHub is down right now, I'll try it in a bit.
Alright, I really don't know if this did it, but I think it is compiled with the static library and it's in the plugin... it jumped in size by 2 MB, so that's a promising sign. :)
Give it a shot, let me know.
also couldn't preflight from the Patches folder.
all in 64 - bit mode QC on a 32 bit boot
then
and
plus
all in 32 bit mode on a 32 bit boot.
The MySQLpatch just fails to be loaded in the Library, which I guess is to be expected from a plugin, as the Console does state, lacking the requiste file at declared path point.
What about loading libtclsqlite3.dylib instead of seeking support for SQL via libmysqlclient.dylib ?
Oh, and I do not have an installed libmysqlclient.la or la_ra but does that really matter much at all when you are looking for /usr/local/mysql/lib/libmysqlclient.15.dylib?
Couldn't you use -single_module linking at compile time ?
I'm not sure that you can create a MySQL client connection using libtclsqlite... I could be wrong.
That's weird that the latest I posted is looking for "/usr/local/mysql/lib/libmysqlclient.15.dylib".
For that last compile, I removed the reference to that directory from Library Search Paths and removed the -lmysqlclient linker flag and instead copied libmysqlclient.a in to the project and added to the Build Phases matching Copy Bundle Resource and Link Binary With Libraries.
Who knows if that'll work. I think the safest bet is to get the source, make sure you've got libmysqlclient.a/.dylib and the required headers and just compile it yourself.
If you're feeling extra perky, I created a "static_library" branch on the GitHub repo (http://github.com/williamcotton/MySQLPatch). Fork the project and do what you will with it! Note, the master branch is for the basic dynamically compiled patch. If you want, I can add your github account to the project, or you could just request an upstream pull.
On a somewhat related note, how about a kineme GitHub account and some of the projects moved over there? :)
Nope, you're right -- SQLite3 can only access on-disk files in the SQLite3 file format. MySQL can connect to MySQL servers. The end result is the same, but the way they go about accomplishing it is radically different. They're not drop-in replacements.
Make sure you make clean, delete the build directory, and recompile it. There shouldn't be any references to the .dylib anywhere (not in the Frameworks folder, nor in the library paths, which you've checked -- also check all the build settings, not just Development or Release).
Alright, let's try this one!
BTW, it's still 32-bit.
I would highly highly recommend using a framework like : http://code.google.com/p/mysql-cocoa-framework/, you will be able to get it 10.6, x86_64 compat for QC 4.0 out of the box.
Would be nice. Im happy to help, but I dont use git/github, nor do I have a huge project currently that would use this, but, I live random projects.
Yeah, I looked at that, but it is really really old, like, back from the Project Builder/pre-Xcode days...
I found some other MySQL cocoa application that just included libmysqlclient.a and then used the C API. I'm pretty sure that's the standard way to do it.
I'll spend a little more time on it, mainly because I'm interested, but with the source code (and mysql_devel) in hand, it should be relatively painless to compile a copy for your own machine.
Of course, that last compile that I posted might work... I have no way to tell! It's been working fine on my machine all day long ;)
BTW, here's what it looks like in action. :)
So I got the plugin working in Snow Leopard pulling from my Dreamhost account, it works perfectly well on launch (it runs any query if you save, close QC and reopen), but when I stop and restart the composition I will get the following error:
I think this could open up a lot of doors for QC, and I'm really glad you're taking an interest in it.
Would it be possible to add an "update" function, like the XML or RSS patches have? Just to refresh the query.
Thanks again for your work!
nice!
I'm glad you got it to compile!
Yup, I'm getting the same error. Yikes, I didn't test start and stopping, hehe.
I'll add update functionality as well... should be pretty easy.
Bug fixed and Update Signal added.
BTW, there are still probably some nasties hidden in there... keep me updated on any more bugs!
I'm guessing you compiled it, right? I'm getting off the computer for the night, so email me and I'll compile one for you tomorrow.
Loads in Library, but really crashes if it's not pointed absolutely right at start time, even entering a key whilst rendering makes it bolt :-)
However the main thing for me with this plugin is to get the details entered as per the sql server account before starting the render.
In a 32 bit boot, it works and looks pretty interesting indeed.
Console output -
very nice!
Very cool!
a|x
I'm having trouble getting the latest version to compile, it's complaining about the arch. for MySQL. I'm going to muck about with it some more and see what I can get.
this just proves how great a qc website could be... well for the apple community.
I can get that kind of reaction as screen captured from QC and my test set up using your patch, but it is quite unsteady and given to crashing QC in 32 bit mode , [no 64 bit mode as pointed out previously], if I'm changing things with the render on whilst editing and also upon a successful connect, albeit sometimes with MySQL error messages, as and when I choose to switch the render off.
Going to back burner this patch into the temporary (Disabled) items folder for the time being.
If you grab the latest version of the source code and compile it locally it seems to be pretty stable.
I'm still going to work on a more stable precompiled version, but it's gonna take some fiddling. It is hard to test because I've got a feeling that the types of errors you're experience have to do with the version of libmysqlclient I compiled it with, which could have traces of links to dynamic libraries from my computer...
Is this plugin not compatible with the Snow Leopard Quartz Composer? Any more developement on this?
I'm also looking...
I tried compiling it myself, but got stuck in the mysql_config, does anyone have a latest build available, or some clues how a total noob on x-code can get this compiled himself? Or are there any alternatives for QC/sql communication?
Thanks!