我可以使用sqlplus
使用:
$ env | grep -E '(TWO|SID)'
TWO_TASK=TEST
$ sqlplus me/my_password@TEST
然后我可以毫无问题地运行以下查询:
select
persons.person.key AS id,
persons.person.lname as lastname,
persons.person.fname as firstname,
sid.organizations.org_code as org,
sid.organizations.division_code as division,
sid.organizations.directorate_code as directorate,
persons.person.status as status
from
persons.person,
sid.organizations
where
persons.person.dept_id=sid.organizations.org_id;
但是,在我的python代码中,使用cx_Oracle
,使用以下代码(即相同的查询):
def get_oracle( user, password, tns='TEST' ):
db = cx_Oracle.connect( user, password, tns )
cursor = db.cursor()
return cursor
db = get_oracle( 'me', 'my_pass' )
db.execute("""
select
persons.person.key AS id,
persons.person.lname as lastname,
persons.person.fname as firstname,
sid.organizations.org_code as org,
sid.organizations.division_code as division,
sid.organizations.directorate_code as directorate,
persons.person.status as status
from
persons.person,
sid.organizations
where
persons.person.dept_id=sid.organizations.org_id;
""")
for r in db:
pass
结果出现以下错误:
cx_Oracle.DatabaseError: ORA-00911: invalid character
我很确定我的连接没问题,因为其他查询工作正常。
答案 0 :(得分:0)
回答我自己的问题,这是一个在查询结尾处带有分号的愚蠢错字!