[英]Copy database from one server to another server + trigger python script on a database event
I've a read-only access to a database server dbserver1. 我对数据库服务器dbserver1具有只读访问权限。 I need to store the result set generated from my query running on dbserver1 into another server of mine dbserver2. 我需要将在dbserver1上运行的查询生成的结果集存储到我的dbserver2的另一台服务器中。 How should I go about doing that? 我应该怎么做呢?
Also can I setup a trigger which will automatically copy new entries that will come in to the dbserver1 to dbserver2? 还可以设置一个触发器,该触发器将自动将进入dbserver1的新条目复制到dbserver2吗? Source and destination are both using Microsoft SQL server. 源和目标都使用Microsoft SQL Server。
Following on that, I need to call a python script on a database trigger event. 接下来,我需要在数据库触发事件上调用python脚本。 Any ideas on how could that be accomplished? 关于如何实现的任何想法?
lad2015 answered the first part. lad2015回答了第一部分。 The second part can be infinitely more dangerous as it involves calling outside the Sql Server process. 第二部分可能会更加危险,因为它涉及在Sql Server进程外部进行调用。
In the bad old days one would use the xp_cmdshell . 在糟糕的过去,人们会使用xp_cmdshell 。 These days it may be more worthwhile to create an Unsafe CLR stored procedure that'll call the python script. 如今,创建一个将调用python脚本的Unsafe CLR存储过程可能更有价值。
But it is very dangerous and I cannot stress just how much you shouldn't do it unless you really have no other choices. 但这是非常危险的,除非您别无选择,否则我无法强调您不应该这样做。
I'd prefer to see a polling python script that runs 100% external to Sql that connects to a Status table populated by the trigger and performs work accordingly. 我更希望看到一个轮询python脚本,该脚本在Sql外部运行100%,该脚本连接到由触发器填充的Status表并相应地执行工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.