在 pymssql 连接 class 中访问 column_types
accessing column_types in pymssql connection class
我正在使用 pymssql 模块。我正在尝试提取列的数据类型。根据 github code 应该可以通过 connection.column_types
访问它但是我得到以下错误:
AttributeError: '_mssql.MSSQLConnection' object has no attribute 'column_types'
我不明白我做错了什么。我有正确的对象,我正在使用 _mssql.connect()
方法创建连接:
pymssql._mssql.connect(server=HOST, port=PORT, user=USR, password=PWD, **KWARGS)
(但即使我使用 DBAPI connect() 方法 pymssql.connect()
:
pymssql.connect(host=HOST, port=PORT, user=USR, password=PWD, **KWARGS)
然后我尝试访问底层连接 class cursor._source._conn.column_types
它也因为同样的原因失败了:
AttributeError: '_mssql.MSSQLConnection' object has no attribute 'column_types'
如何获取数据类型?
我在 github 上开了一张票,got an answer。在这里发帖是为了后代和完整性。
column_types
is cdef
so only accessible from C code, not Python.
这不是我所希望的,但唉,这就是答案。
我正在使用 pymssql 模块。我正在尝试提取列的数据类型。根据 github code 应该可以通过 connection.column_types
访问它但是我得到以下错误:
AttributeError: '_mssql.MSSQLConnection' object has no attribute 'column_types'
我不明白我做错了什么。我有正确的对象,我正在使用 _mssql.connect()
方法创建连接:
pymssql._mssql.connect(server=HOST, port=PORT, user=USR, password=PWD, **KWARGS)
(但即使我使用 DBAPI connect() 方法 pymssql.connect()
:
pymssql.connect(host=HOST, port=PORT, user=USR, password=PWD, **KWARGS)
然后我尝试访问底层连接 class cursor._source._conn.column_types
它也因为同样的原因失败了:
AttributeError: '_mssql.MSSQLConnection' object has no attribute 'column_types'
如何获取数据类型?
我在 github 上开了一张票,got an answer。在这里发帖是为了后代和完整性。
column_types
iscdef
so only accessible from C code, not Python.
这不是我所希望的,但唉,这就是答案。