Page 1 of 1

workpad to mysql?

Posted: Thu Mar 11, 2010 3:41 pm
by ois
I know you can go from channels automagically to mysql via a channel hook.
Is it possible to have the workpad contents go into mysql in a report generating kind of way?
What's involved?

Cheers!

Re: workpad to mysql?

Posted: Thu Mar 11, 2010 8:22 pm
by support
ois wrote:Is it possible to have the workpad contents go into mysql in a report generating kind of way?

Not directly but it would be possible to jury-rig something up.

For example, 2.4.2 introduced the ability to run a command after a report has been generated so you could write a template that exported the workpad contents to, say, XML, then write a script that imported that XML content into MySQL.

It would even be possible to use the MySQL channel hook to do this. When it calls channel hooks, Awasu generates an INI file with all the relevant information and then runs the channel hook with the path to that INI file as its argument. So, you write a template that exported the workpad content to an INI file, then configure the report to run the hook after it has been generated. The hook won't know that it is being called because a report has been generated rather than the usual "new content has arrived" event and will do its usual thing of importing the content into the database.

Alternatively, 2.4.2 also introduced HTTP calls that allow workpad content to be retrieved so you could set up a cron job that called that and imported the content into the database.

Re: workpad to mysql?

Posted: Thu Mar 11, 2010 8:28 pm
by kevotheclone
You might be able to adapt the MySQL Channel Hook to do this task, by creating a Channel Report that looks like the file that the MySQL Channel Hook expects to see from Awasu when it's being used in its normal Channel Hook context. Of course Taka will know best if this would work. :unsure:

I don't have any MySQL experience, but a quick search led to the "mysqlimport" command line tool. You could create a Channel Report that exports Workpad data in a delimited, flat-file format, which could be imported with "mysqlimport". Awasu version 2.4.2 can run a command after Awasu creates a Channel Report, so you could 1) produce a delimited, flat-file from your Workpad, and the 2) run "mysqlimport" to import it into MySQL. Of course Channel Reports can be run, 1) manually, 2) at set intervals, 3) at set times or 4) every time a new item is added to the Workpad; "versatility deluxe". :D

Re: workpad to mysql?

Posted: Thu Mar 11, 2010 9:37 pm
by support
kevotheclone wrote:You might be able to adapt the MySQL Channel Hook to do this task

Great minds think alike :-)

kevotheclone wrote:a quick search led to the "mysqlimport" command line tool.

Meh, why bother? Just write the template to generate SQL and then run <tt>mysql.exe</tt> to import it :hysterical:

Sometimes even I get impressed by Awasu's versatility :roll:

thanks

Posted: Sat Mar 13, 2010 1:16 pm
by ois
thanks - just updated and soon to embark on the learning curve that is channel hooks & command lines!