SnapLogic Python 读取和执行 SQL 文件

我有一个简单的 SQL 文件,我想在 SnapLogic 中使用 Python Script Snap 读取和执行该文件。我创建了一个表达式库文件来引用 Redshift 帐户,并将其作为参数包含在管道中。


我从另一篇文章中获得了以下代码。有没有办法引用管道参数连接到Redshift数据库,读取上传的SQL文件并执行命令?


fd = open('shared/PythonExecuteTest.sql', 'r')

sqlFile = fd.read()

fd.close()


sqlCommands = sqlFile.split(';')


for command in sqlCommands:

    try:

        c.execute(command)

    except OperationalError, msg:

        print "Command skipped: ", msg


江户川乱折腾
浏览 193回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python