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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值