【发布时间】:2017-08-14 12:21:34
【问题描述】:
我在我的 postgresql 表中添加了一个新列。 现在我想向这个新添加的列添加值。 我发现的唯一命令允许添加值,但不允许在列的选定行中添加值。 我想要的是:
cursor.execute('SELECT Column_name FROM Table_name')
rows = cursor.fetchall()
cursor.execute('ALTER TABLE Table_name ADD NewColumn_name type')
for row in rows:
#Here I want to have a commands that adds a value (result of a function: func(row)) to every row of the new column, one by one something like:
NewColumn_name[i] = func(row)
i = i+1
【问题讨论】:
-
什么是主键或唯一列?
-
func是做什么的?
标签: python sql postgresql psycopg2