如何在其他数据库中将它们插入相同的字段 [英] How to insert they same field in other database

查看:87
本文介绍了如何在其他数据库中将它们插入相同的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有2个数据库。两个数据库的列名称如下:

Lets say i have 2 databases.The column names of the two databases are as follows:

db1: name, age, gender, mother_name, father_name  
db2: name, gender, status, birthdate

可以看到,db1和db2都具有名称和性别的公共字段。我想将db2中的数据插入db1中,它们具有相同的字段。

As you can see, both db1 and db2 have common fields of 'name' and 'gender'. I want to insert the data from db2 in db1 which have they same fields.

推荐答案

如果给我们期望的输出,它可以更精确。但是据我了解:

if you give us an expected output it could be more precise. But as i understand:

db1 = db1.merge(db2, on=["name","gender"], how="left")

这篇关于如何在其他数据库中将它们插入相同的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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