我应该将驻留在Server A
上的现有Postgres DB的部分数据播种到驻留在Server B
上的另一个Postgres DB。除了创建API和在Rake Task中执行或使用seeds.rb
之外,还有其他有效的方法吗?
更多详细信息
我尝试了@Siim Liiser建议的方法,但是它创建了表中所有数据而不是选定记录的转储。有什么方法可以在转储选项中添加where
子句?
答案 0 :(得分:1)
使用 <script>
var count = 1;
let mainElement = document.querySelector("div.main>.imgSub");
let URL = "https://www.takushoku-u.ac.jp/summary/images/summary_successive-chancellor_img_";
let thumbnailsElement = document.querySelector("div.thumbnails");
thumbnailsElement.children[count-1].classList.add('selected');
function next() {
if (count < 19) {
count++;
if (count < 10) {
console.log("count:" + count);
x = URL + "0" + count + ".jpg";
} else {
x = URL + count + ".jpg";
}
} else {
count = 1;
x = URL + "0" + count + ".jpg";
}
mainElement.setAttribute('src', x);
thumbnailsElement.children[count].classList.remove('selected');
thumbnailsElement.children[count-1].classList.add('selected');
thumbnailsElement.children[count-2].classList.remove('selected');
}
function prev() {
if (count > 1) {
if (count < 10) {
count--;
x = URL + "0" + count + ".jpg";
} else {
count--;
x = URL + count + ".jpg";
}
} else if (count == 19) {
count = 1;
x = URL + count + ".jpg";
}
mainElement.setAttribute('src', x);
thumbnailsElement.children[count].classList.remove('selected');
thumbnailsElement.children[count-1].classList.add('selected');
thumbnailsElement.children[count-2].classList.remove('selected');
}
//play stop reset buttons
let timer;
let nowPlaying = false;
function autoPlay() {
next();
timer = setTimeout(function() {autoPlay();}, 1000);
}
function play() {
if (nowPlaying == true) {
return;
}
nowPlaying = true;
autoPlay();
}
function stop() {
clearTimeout(timer);
nowPlaying = false;
}
function reset() {
stop();
thumbnailsElement.children[count].classList.remove('selected');
thumbnailsElement.children[count-1].classList.remove('selected');
count = 1;
thumbnailsElement.children[count-1].classList.add('selected');
URL = URL + "01.jpg";
mainElement.setAttribute('src', URL);
}
</script>
将pg_dump
中的数据存储到文件中。有很多选项可以选择要导出的部分数据。最有用的可能是指定所需的表。
将该文件移至Server A
(Server B
或您希望使用的任何其他工具)上,然后scp
移至pg_restore
上的数据库中。
我认为这是一次简单的一次性动作的最佳解决方案。当然,为此构建一个api也可以,但是工作更多,执行起来更慢。