![]() |
Python Connector for SQL Server Data types - Python Connector for SQL Server |
![]() |
The following table describes the supported SQL Server data types and their mapping to the Python data types. The type codes returned in the description
cursor attribute can be used in the addtypecast()
cursor method.
SQL Server data type | Type code | Python data type |
---|---|---|
bit |
301 |
int |
tinyint |
302 |
int |
smallint |
303 |
int |
int |
304 |
int |
bigint |
305 |
int |
decimal |
306 |
float |
numeric |
307 |
float |
smallmoney |
308 |
float |
money |
309 |
float |
real |
310 |
float |
datetime |
311 |
datetime.datetime |
smalldatetime |
312 |
datetime.datetime |
date |
313 |
datetime.date |
time |
314 |
datetime.time |
datetime2 |
315 |
datetime.datetime |
char |
317 |
str |
varchar |
318 |
str |
text |
319 |
str |
nchar |
320 |
str |
nvarchar |
321 |
str |
ntext |
322 |
str |
binary |
323 |
binary |
varbinary |
324 |
binary |
image |
325 |
binary |