如何在从CSV文件复制数据时在GreenPlum中插入记录。 CSV文件具有针对给定主键值的多个记录。如果数据库中已存在具有某些值的行,则我想更新该记录。否则,它应该追加一个新行。
答案 0 :(得分:0)
执行此操作的一种方法是将数据复制到临时表,然后从该表中插入/更新。
以下是一个例子:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
from matplotlib.offsetbox import AnnotationBbox, AuxTransformBox
# Here's my "image"
X = np.arange(16).reshape(4,4)
# Suppose I want to highlight some feature in the middle boxes.
fig = plt.figure()
ax = fig.add_subplot(111)
ax.imshow(X, cmap=plt.cm.gray, interpolation='nearest', aspect="auto")
linewidth=14
xy, w, h = (0.5, 0.5), 2, 2
r = Rectangle(xy, w, h, fc='none', ec='gold', lw=1)
offsetbox = AuxTransformBox(ax.transData)
offsetbox.add_artist(r)
ab = AnnotationBbox(offsetbox, (xy[0]+w/2.,xy[1]+w/2.),
boxcoords="data", pad=0.52,fontsize=linewidth,
bboxprops=dict(facecolor = "none", edgecolor='r',
lw = linewidth))
ax.add_artist(ab)
plt.show()