0

我正在尝试将参数从 python 传递给 SQL 脚本。

下面是我正在尝试的脚本;请让我知道我在这里做错了什么......

#!./bin/python
_author_='Mohammed'

import boto3
import cx_Oracle
import sys

con = cx_Oracle.connect('username/password@localhost:1521/DBName')
print con.version
cur=con.cursor()
statements = open('$location/test.sql').read().format('localhost')
cur.execute(statements)
query_result=cur.fetchall()
for res in query_result:
print(res)

************错误***********

Traceback (most recent call last):
  File "$location\test1.py", line 19, in <module>
    statements = open('$location/test.sql').read().format('localhost')
IndexError: tuple index out of range
4

0 回答 0