使用Python2.7.12和包cx_Oracle
我试图创建一个扩展类,包称之为OracleCursor。我只想从超类继承方法并用一些自定义方法进行扩展。在
首先,我通过
import cx_Oracle
conn = cx_Oracle.connect(username, password, dsn)
cursor = conn.cursor()
然后我有以下内容
^{pr2}$人们会认为它是通过
class ExtendedCursor(cx_Oracle.Cursor):
def hello_world(self):
print('Hello world')
extended = ExtendedCursor(cursor)
但我得到TypeError: argument 1 must be cx_Oracle.Connection, not OracleCursor
。对我来说,这个错误没有意义。另外,我不能使用OracleCursor
作为我的超类,因为它没有被识别为一个类。在
从Connection对象返回游标。您需要创建一个返回ExtendedCursor的自定义连接。
退货:
^{pr2}$相关问题 更多 >
编程相关推荐