将数据从 SQL 服务器传输到雪花时 python 出错

Getting error on python while transferring data from SQL server to snowflake

我遇到了以下错误

query = command % processed_params TypeError: not all arguments converted during string formatting

我正在尝试从 SQL 服务器中提取数据,然后将其插入 Snowflake 我下面的代码

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])

明显是字符串解析错误。 您没有为 %s 打印输出提供参数。

如果您无法解决问题,请退一步尝试其他方法。 使用另一个脚本来实现同样的效果,明天再回复你 :-)

我的脚本做的几乎一样:

1. Connect to SQL Server
    -> fetchmany
        -> multipart upload to s3
            -> COPY INTO Snowflake table

详情在这里:Snowpipe-for-SQLServer