Huginn's agent for execute custom MySQL query.
Set connection url and write query – selected rows will be emitted as events.
Add huginn_mysql2_agent
to your Huginn's ADDITIONAL_GEMS
configuration:
# docker env
environment:
ADDITIONAL_GEMS: 'huginn_mysql2_agent(git: https://github.com/yubuylov/huginn_mysql2_agent.git)'
# .env (Local huginn installation)
ADDITIONAL_GEMS=huginn_mysql2_agent(github: yubuylov/huginn_mysql2_agent)
- Set db connections url:
mysql2://user:pass@localhost/database
Use it raw or like credential {% credential mysql_connection %}
- Write SQL:
select id, title, age, weight from tbl_girls where age >= 18 order by weight, age limit 2
Will be emitted events:
[
{"id":123456762, "title": "Ann", "age": 21, "weight": 45},
{"id":123456713, "title": "Julia", "age": 18, "weight": 47}
]
Please checkout the Huginn MySQL example Screencast!
Running rake
will clone and set up Huginn in spec/huginn
to run the specs of the Gem in Huginn as if they would be build-in Agents. The desired Huginn repository and branch can be modified in the Rakefile
:
HuginnAgent.load_tasks(branch: '<your branch>', remote: 'https://github.com/<github user>/huginn.git')
Make sure to delete the spec/huginn
directory and re-run rake
after changing the remote
to update the Huginn source code.
After the setup is done rake spec
will only run the tests, without cloning the Huginn source again.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
to create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
- Fork it ( https://github.com/[my-github-username]/huginn_mysql2_agent/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request