pyodbc.Row对象:元组的值是多少

问题描述

我已连接到数据库并具有光标。我希望获得每列的列名和数据类型。

我的代码是这样的:

for row in cursor.columns(table='my_table'):
  print(row)
  print(type(row))

输出是这样

('data','dbo','my_table','system_code',-9,'nvarchar',10,20,None,1,'NO',39)
<class 'pyodbc.Row'>

我找不到有关这些值代表什么的文献。我可以通过运行以下命令来get the column name

for row in cursor.columns(table='my_table'):
    print row.column_name

因此column_name一个属性-其他属性名称是什么?这些记录在某处吗?

解决方法

pyodbc Wiki Cursor#columns在pyodbc Wiki中有记录:

Each row has the following columns:

 1. table_cat
 2. table_schem
 3. table_name
 4. column_name
 5. data_type
 6. type_name
 7. column_size
 8. buffer_length
 9. decimal_digits
10. num_prec_radix
11. nullable
12. remarks
13. column_def
14. sql_data_type
15. sql_datetime_sub
16. char_octet_length
17. ordinal_position
18. is_nullable: One of SQL_NULLABLE,SQL_NO_NULLS,SQL_NULLS_UNKNOWN.

https://github.com/mkleehammer/pyodbc/wiki/Cursor#columnstablenone-catalognone-schemanone-columnnone