简体   繁体   English

将数据库从一台服务器复制到另一台服务器,并在数据库事件上触发python脚本

[英]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.

相关问题 使用 Python 在 SQL Server 中将表从一个数据库复制到另一个数据库 - Copy tables from one database to another in SQL Server, using Python Python 脚本将文件和目录从一台远程服务器复制到另一台远程服务器 - Python script to copy file and directory from one remote server to another remote server Python SocketIO Server-如何触发从一个命名空间到另一个命名空间的事件? - Python SocketIO Server- how do I trigger event from one namespace to another? 使用Python将数据从一个Oracle数据库复制到另一个数据库 - Copy data from one oracle database to another with Python PostgreSQL Python将表从一个数据库复制到另一个数据库 - PostgreSQL Python copy table from one database to another 从Python将整个SQL Server数据库复制到JSON - Copy whole SQL Server database into JSON from Python Python脚本将数据从一台MySQL服务器传输到另一台MySQL服务器 - Python script to transfer data from one MySQL server to another one 从 sql-server 数据库到另一个数据库创建所有表及其键和其他约束的副本 - create a copy of all tables with its key and other constraints from sql-server database to another database 从Web服务器在AWS上触发Python脚本 - Trigger a Python Script on AWS from Web Server 如何将参数从服务器上的一个python脚本传递给另一个? - How to pass arguments from one python script on the server to another?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM