如何使用 Python 更新、插入和删除 Redshift 数据库?

Posted

技术标签:

【中文标题】如何使用 Python 更新、插入和删除 Redshift 数据库?【英文标题】:How to update, insert and delete Redshift database using Python? 【发布时间】:2020-07-13 19:44:44 【问题描述】:

我可以使用 psycopg2 库创建表,但是我无法更新和删除 Redshift 数据库中的记录。请建议一些方法来做到这一点。

【问题讨论】:

【参考方案1】:

您可以在他们的文档中找到很多有用的信息:here

这里有一个小sn-p供你参考。

with conn.cursor() as sql_cursor:
  sql_cursor.execute('delete from table_1 where col1=123')

另外,请确保您用于更新或删除的 db 用户有权这样做。

【讨论】:

以上是关于如何使用 Python 更新、插入和删除 Redshift 数据库?的主要内容,如果未能解决你的问题,请参考以下文章