私の知る限り、標準の Python DB API は、結果行セットの正確な SQL タイプ情報を提供しません。
int、str ... のような切り詰められた python 型ではなく、結果行セットの正確な SQL 型と tinyint、bigint、nvarchar(100) などのより詳細な情報を取得する方法はありますか?
移植性やモジュールの依存関係は重要ではないと思います-何かがうまくいくだけです。(私はWindows、MS-SQLで作業しています。)
私の知る限り、標準の Python DB API は、結果行セットの正確な SQL タイプ情報を提供しません。
int、str ... のような切り詰められた python 型ではなく、結果行セットの正確な SQL 型と tinyint、bigint、nvarchar(100) などのより詳細な情報を取得する方法はありますか?
移植性やモジュールの依存関係は重要ではないと思います-何かがうまくいくだけです。(私はWindows、MS-SQLで作業しています。)
クエリの後に使用.description
して、特にデータ型に関する情報を取得します。
cursor.execute('select some_column from some_table')
print cursor.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)