使用 Python 将数据插入 AWS S3 数据库 table 时出错
Error to Insert data into a AWS S3 database table using Python
我正在尝试使用 Python 将数据插入 AWS S3 数据库 table。
由于某种原因,我得到可选的第二个参数 must be a list or tuple in error,
我的数据没有被插入到数据库中。
代码如下,
import boto3
s3 = boto3.resource('s3')
bucket = s3.Bucket('testing')
cursor = context.cursor()
sql_data = [0,2,3,4,5,6]
for x in sql_data:
print(x)
query = "INSERT INTO items (id) VALUES (%s);"""
cursor.execute(query, sql_data)
#or
#cursor.execute(query, x)
当我写/用下面的查询替换上面的查询时,它可以工作,但我想从数组中插入数据。
"""insert into items (id) values (1)"""
"""insert into items (id) values (2)"""
"""insert into items (id) values (3)"""
我收到 可选的第二个参数必须是列表或元组错误
你的语法有误。将 %s
替换为 ?
我正在尝试使用 Python 将数据插入 AWS S3 数据库 table。 由于某种原因,我得到可选的第二个参数 must be a list or tuple in error, 我的数据没有被插入到数据库中。 代码如下,
import boto3
s3 = boto3.resource('s3')
bucket = s3.Bucket('testing')
cursor = context.cursor()
sql_data = [0,2,3,4,5,6]
for x in sql_data:
print(x)
query = "INSERT INTO items (id) VALUES (%s);"""
cursor.execute(query, sql_data)
#or
#cursor.execute(query, x)
当我写/用下面的查询替换上面的查询时,它可以工作,但我想从数组中插入数据。
"""insert into items (id) values (1)"""
"""insert into items (id) values (2)"""
"""insert into items (id) values (3)"""
我收到 可选的第二个参数必须是列表或元组错误
你的语法有误。将 %s
替换为 ?