pymssql の結果から列名を取得する方法はありますか? as_dict=True を指定すると、すべての列ヘッダーを含むディクショナリが返されますが、それはディクショナリであるため、順序付けされていません。
14862 次
4 に答える
16
pymssql は Python DB-API.description
をサポートすると主張しているため、カーソル オブジェクトから属性を取得できるはずです。
。説明
This read-only attribute is a sequence of 7-item sequences. Each of these sequences contains information describing one result column: (name, type_code, display_size, internal_size, precision, scale, null_ok)
したがって、「内部」シーケンスのそれぞれの最初の項目は、各列の名前です。
于 2011-03-04T05:27:20.970 に答える