Python 条连接到 Oracle 的记录
Python records connecting to Oracle
我正在使用 Kenneth Ritz 的记录库连接到 Oracle。
db = records.Database('oracle://scott/tiger@localhost:1521/orcl')
但它总是抛出这个错误
DatabaseError: (cx_Oracle.DatabaseError)
ORA-12545: Connect failed because target host
or object does not exist.
但是,通过 SQL Plus 连接就可以了
sqlplus scott/tiger@localhost/orcl:1521
SQL*Plus: Release 12.1.0.1.0 Production on Sat Mar 11 17:29:19 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Last Successful login time: Sat Mar 11 2017 17:16:24 +05:30
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL>
有趣的观察
db = cx_Oracle.connect('scott/tiger@localhost:1521/orcl') **<--Works**
db.version
'12.1.0.1.0'
db = records.Database('oracle+cx_oracle://scott/tiger@localhost:1521/orcl')
doesn't work
知道我做错了什么吗?
records
依靠 sqlalchemy
来完成数据库的繁重工作。
请参考SQLAlchemy documentation:
所以,URI 应该是这样的:
oracle+cx_oracle://user:pass@localhost:1521/dbname
我正在使用 Kenneth Ritz 的记录库连接到 Oracle。
db = records.Database('oracle://scott/tiger@localhost:1521/orcl')
但它总是抛出这个错误
DatabaseError: (cx_Oracle.DatabaseError)
ORA-12545: Connect failed because target host
or object does not exist.
但是,通过 SQL Plus 连接就可以了
sqlplus scott/tiger@localhost/orcl:1521
SQL*Plus: Release 12.1.0.1.0 Production on Sat Mar 11 17:29:19 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Last Successful login time: Sat Mar 11 2017 17:16:24 +05:30
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL>
有趣的观察
db = cx_Oracle.connect('scott/tiger@localhost:1521/orcl') **<--Works**
db.version
'12.1.0.1.0'
db = records.Database('oracle+cx_oracle://scott/tiger@localhost:1521/orcl')
doesn't work
知道我做错了什么吗?
records
依靠 sqlalchemy
来完成数据库的繁重工作。
请参考SQLAlchemy documentation:
所以,URI 应该是这样的:
oracle+cx_oracle://user:pass@localhost:1521/dbname