pyodbc.Row 对象:元组值是什么
pyodbc.Row object: what are the tuple values
我已连接到数据库并有一个游标。我想获取每一列的列名和数据类型。
我的代码是这样的:
for row in cursor.columns(table='my_table'):
print(row)
print(type(row))
输出是这样的:
('data', 'dbo', 'my_table', 'system_code', -9, 'nvarchar', 10, 20, None, None, 0, None, None, -9, None, 20, 1, 'NO', 0, 0, 0, 0, None, None, None, None, None, None, 39)
<class 'pyodbc.Row'>
我找不到关于这些值代表什么的文档。我可以通过 运行 来 get the column name:
for row in cursor.columns(table='my_table'):
print row.column_name
所以 column_name
是一个属性 - 其他属性名称是什么?这些是否记录在某处?
pyodbc 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
我已连接到数据库并有一个游标。我想获取每一列的列名和数据类型。
我的代码是这样的:
for row in cursor.columns(table='my_table'):
print(row)
print(type(row))
输出是这样的:
('data', 'dbo', 'my_table', 'system_code', -9, 'nvarchar', 10, 20, None, None, 0, None, None, -9, None, 20, 1, 'NO', 0, 0, 0, 0, None, None, None, None, None, None, 39)
<class 'pyodbc.Row'>
我找不到关于这些值代表什么的文档。我可以通过 运行 来 get the column name:
for row in cursor.columns(table='my_table'):
print row.column_name
所以 column_name
是一个属性 - 其他属性名称是什么?这些是否记录在某处?
pyodbc 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