为什么我会收到此Python数据库连接错误?

问题描述 投票:-2回答:1

错误:tns:listener未在connect_data中获得service_name

import cx_Oracle
con = cx_Oracle.connect('hr/hr@localhost')
if  con!= None:
    print('Connection established successfully')
    print('Version:',con.version)
else:
    print('Connection not established')
con.close()
python cx-oracle
1个回答
0
投票
import cx_Oracle
con = cx_Oracle.connect('hr/hr@localhost:1521/orcl')
if  con!= None:
    print('Connection established successfully')
    print('Version:',con.version)
else:
    print('Connection not established')
con.close()
© www.soinside.com 2019 - 2024. All rights reserved.