Calling an url from a trigger in mysql

前端 未结 3 1562
春和景丽
春和景丽 2020-12-10 01:55

I know it\'s highly unrecommended,

I know that it\'s an issue with performance, speed, etc, but it\'s for an integration, and they only are doing their updates via m

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-10 02:55

    Here's a solution for a MySQL server 5.6 64bit(!) on Windows platform. I tested it under Win10 64bit. I needed a 64bit .dll version of a plugin which gives you functionality to run a command in a shell, a working one I found here: http://winadmin.blogspot.nl/2011/06/mysql-sysexec-udf-for-64-bit-windows.html

    You could also compile it yourself on Windows see: http://rpbouman.blogspot.nl/2007/09/creating-mysql-udfs-with-microsoft.html

    For MySQL 5.1+ you have to put the plugin/dll in a subdir of your MySQL installation root for example C:\wamp\bin\mysql\mysql5.6.17\lib\plugin Or else you get an error:

    Can not open shared library dll – errorcode 193

    You also need curl.exe which is called by sys_eval. You need to download the correct one here (be sure to copy both(!) files .exe and .crt to a reachable path from your PATH env. var), I used c:\windows\system32 : https://winampplugins.co.uk/curl/

    Then only code you need is:

    --one time setup. run inside your database
    CREATE FUNCTION sys_eval RETURNS STRING SONAME ‘lib_mysqludf_sys.dll’;
    
    --example call to an URL
    select CONVERT(sys_eval(CONCAT(‘curl https://randomuser.me/api?results=1‘)) USING UTF8MB4);
    

提交回复
热议问题