[英]Getting error on python while transferring data from SQL server to snowflake
I am getting below error我得到以下错误
query = command % processed_params TypeError: not all arguments converted during string formatting
查询 = 命令 % 处理参数类型错误:并非所有参数都在字符串格式化期间转换
I am trying to pull data from SQL server and then inserting it into Snowflake my below code我正在尝试从 SQL 服务器中提取数据,然后将其插入雪花我下面的代码
import pyodbc
import sqlalchemy
import snowflake.connector
driver = 'SQL Server'
server = 'tanmay'
db1 = 'testing'
tcon = 'no'
uname = 'sa'
pword = '123'
cnxn = pyodbc.connect(driver='{SQL Server}',
host=server, database=db1, trusted_connection=tcon,
user=uname, password=pword)
cursor = cnxn.cursor()
cursor.execute("select * from Admin_tbldbbackupdetails")
rows = cursor.fetchall()
#for row in rows:
# #data = [(row[0], row[1],row[2], row[3],row[4], row[5],row[6], row[7])]
print (rows[0])
cnxn.commit()
cnxn.close()
connection = snowflake.connector.connect(user='****',password='****',account='*****')
cursor2 = connection.cursor()
cursor2.execute("USE WAREHOUSE FOOD_WH")
cursor2.execute("USE DATABASE Test")
sql1="INSERT INTO CN_RND.Admin_tbldbbackupdetails_ip"
"(id,dbname, dbpath, backupdate, backuptime, backupStatus, FaildMsg, Backupsource)"
"values (?,?,?,?,?,?,?,?)"
cursor2.execute(sql1,*rows[0])
It's obviously string parsing error.这显然是字符串解析错误。 You missed to provide parameter to
%s
printout.您没有为
%s
打印输出提供参数。
If you cannot fix it step back and try another approach.如果您无法修复它,请退后一步并尝试另一种方法。 Use another script to achieve the same and get back to you bug tomorrow :-)
使用另一个脚本来实现相同的功能,并在明天回复您的错误:-)
My script is doing pretty much the same:我的脚本几乎是一样的:
1. Connect to SQL Server
-> fetchmany
-> multipart upload to s3
-> COPY INTO Snowflake table
Details are here: Snowpipe-for-SQLServer详细信息在这里: Snowpipe-for-SQLServer
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.