Access MySQL from ExtendScript
Copy link to clipboard
Copied
Did anyone use ExtendScript to connect to a MySQL database, for retrieving and storing data?
Copy link to clipboard
Copied
Hi Jang, I have not done this with ExtendScript. I am sure you already know this, but for the record, you can use FrameScript to connect to ODBC databases.
With ExtendScript, you could use XML as an intermediary format between the database and ExtendScript.
Rick
Copy link to clipboard
Copied
Thanks Rick, but FrameScript is not an option here. And using XML does not solve the problem, as I would need to fire some script from elsewhere to do the pushing and pulling of data. I currently write a series of SQL queries into a text file and have the customer execute the textfile from a PHP script running on their web server. For a localization project I would want to pull little bits of info out of the SQL database on the fly, i.e. using an ExtendScript that might then become event-triggered. The format to exchange info is not changing the need for an active link.
I am investigating sockets. From the CS6 JavaScript Tools Guide, that seems to be the right candidate to make this work. I will keep people posted on my progress. If anyone has used sockets before, please share some working code samples.
Ciao
Copy link to clipboard
Copied
Hi Jang, I know Russ Ward has some sample code using the socket object. I am sure he will give you some advice. Rick
Copy link to clipboard
Copied
Only if he still likes me .
Hey Russ, what's up? You've been quiet on the forum lately.
In the meantime I have found some info about the best way to go forward. As the MySQL database will run on the same server that publishes the web help and security issues normally prohibit direct access to that database, I will create some PHP to execute the queries I send to the socket. Should not be too complex, I hope.
Ciao
Copy link to clipboard
Copied
Hi Jang,
I am curious about whether you have made any additional progress on FrameMaker database connectivity via Extendscript. I'm attempting to replace/augment an existing FrameScript with an Extendscript implementation, so I'm seeking a similar solution.
-Alan
Copy link to clipboard
Copied
no reply from everJang so far?
Read online there's ways to make HTTP calls from ExtendScript via Bridgetalk. So while not specific to FrameMaker, this might be a way to go that I think is generic across Adobe apps:
Loads data from a URL in Adobe Illustrator, synchronously! (Uses Bridge behind the scenes)
and the asynchronous version:
Loads data from a URL in Adobe Illustrator! (Uses Bridge behind the scenes)
one would then just need to tailor the code to fit the specific web service or PHP web page/script to call that does the DB stuff.
Copy link to clipboard
Copied
Sorry, I did not see there were replies to this forum. I was getting too much mail from all kinds of forums so I shut down some of the notification mailers.
What I used in connecting to MySQL is a dedicated PHP server (you can get a MicroServer with PHP and MySQL that only requires 10 MBytes and no installation to run - it could even run from a USB stick if you want) with a couple of pages that handle the MySQL access. I pass the Query as an argument to the URL for the PHP page and my PHP script returns the info from the database, preceded by the usual HTTP header into. I inject a DATA: string as a marker for the ExtendScript to strip off the header part. For communication between the ExtendScript and the PHP server I use a socket, which is part of the JavaScript on which ExtendScript was based. Works, is basic and fast enough. No need for Bridge in the background (if you do not have that installed) or any elaborate protocol handling (like ODBC) or obese MS stuff (like ActiveX objects). Works (almost ?) anywhere. I do love hi-tech, but when lo-tech works, I love that even better. Keep it simple.
Jang
Copy link to clipboard
Copied
I don't think your solution is lo-tech Jang, just one of several different architectural solutions.
Copy link to clipboard
Copied
check out the library porky.io, it lets you handle all those mysql and json/xml requirements

