pyodbc-的一些说明

cursor的description 可以获得一些关于表的信息

info=cursor.description
此时表中有多少列就有多少个元素,一个元素就是一列的信息(格式是tuple),所以这里的info是个2层的tuple。
想要获得所有的列名,就用info[0][0], info[1][0], ......
在打开excel时,第一行默认是标题,不可更改。
打开不同的数据库就是连接不同,其他的用法都一样。
=========================================================
下面的来自官网,对description的说明
https://github.com/mkleehammer/pyodbc/wiki/Cursor#description

description

This read-only attribute is a list of 7-item tuples, one tuple for each column returned by the last SQL select statement. Each tuple contains:

  1. column name (or alias, if specified in the SQL)
  2. type code
  3. display size (pyodbc does not set this value)
  4. internal size (in bytes)
  5. precision
  6. scale
  7. nullable (True/False)
原文地址:https://www.cnblogs.com/beforeluck-shang/p/8370836.html