我有一个简单的 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
相关分类