如何从mysql查询中运行python脚本? [英] how to run the python script from the mysql query?

查看:96
本文介绍了如何从mysql查询中运行python脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望从mysql查询中调用python脚本.

I have a desire to call the python script from the mysql query.

就像我们在mysql中调用过程一样:调用procedurename();

like we call the procedure in mysql : call procedurename();

就像上面一样,mysql中没有任何方法可以调用外部脚本,如

just like as above is there any way in mysql to call external scripts like ,

                       call script(somefile.py) 

我写了上面的东西来解释我到底想要什么.

i wrote the above thing to explain the exactly what i want.

推荐答案

出于安全原因,这在MySQL中似乎无法实现.您可以查看以下相关问题:从MySQL执行shell命令.但是,您可以在其他数据库(如oracle)中执行此操作.在Postgresql中,还支持在数据库中创建 Python存储过程 .您可以使用此技术使您的数据库触发器运行python代码.

This does not seem to be possible in MySQL, for security reasons. You can have a look at this related question Executing shell command from MySQL. You can however do this in other database like oracle. In Postgresql there is also support to create python stored procedures in the database. You could use this technique to have your database triggers run python code.

这篇关于如何从mysql查询中运行python脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆