NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI
PyPI, #657 most downloaded on PyPI
DB API module for ODBC
Latest stable
5.5.0
Last release 14 days ago
08 Nov 2026
Ships fairly regularly
a new release about every 5 months
Some releases are documented
notes for 33 of 60 stable releases
1 version withdrawn
withdrawn after publishing
12 years old
66 releases · first in 2015
Drag across the ruler to compare, or tap a release to open it.
Connection.fetch_decimal_as_string is deprecated; see "Upgrading from 5.4.0".
Version 5.5.0 has been released with wheels for Python 3.11 - 3.15
This release follows 5.4.0 closely. It fixes DECIMAL and NUMERIC values that 5.4.0 and earlier
versions read or wrote incorrectly, mostly with PostgreSQL. It also fixes crashes and
memory-safety bugs found in a review of the C++ code prompted by #1515. Most of the
memory-safety bugs need an unusual setting, value, or driver to reach, but we recommend that
everyone upgrade. It is 5.5.0 rather than 5.4.1 because it adds Connection.decimal_mode;
there will be no 5.4.1.
Decimal NaN or Infinity stored 0. In 5.4.0 and earlier, Cursor.execute()Decimal('NaN'), Decimal('sNaN'), Decimal('Infinity'), or Decimal('-Infinity')SystemError, but only after the statement had run with the value 0. IfNaN, Infinity, and -Infinity wereDecimal('0'), and values with more than 38 digits or more than 38 decimal placesIf you followed the 5.4.0 notes and set Connection.fetch_decimal_as_string = True, it still
works, but it now raises a FutureWarning, and it will be removed in 6.0. Use
Connection.decimal_mode instead:
TrueFalse selects'binary', which reads them as 0.decimal_mode = 'locale' behaves exactly likefetch_decimal_as_string = True. If your driver never adds thousands separators,decimal_mode = 'text' is stricter and is not affected by the locale.Reading fetch_decimal_as_string also raises FutureWarning. To silence it until you
update your code:
warnings.filterwarnings("ignore", message=".*fetch_decimal_as_string", category=FutureWarning)Connection.decimal_mode selects how DECIMAL and NUMERIC values are read:
'binary': into a SQL_NUMERIC_STRUCT, which is not affected by the locale. This is the'text': as text from drivers that never add thousands separators. The decimal point can. or ,, whatever the locale, and NaN, Infinity, and -Infinity are read.DataError rather than being guessed at. This is the default for'locale': the text path from before 5.4, which removes thousands separators and currencysetDecimalSeparator().Decimal NaN, Infinity, and -Infinity can be written with Cursor.execute().DataError). fast_executemany and table-valued parameters cannot sendProgrammingError, as does a signaling NaN.decimal_mode == 'text').Connection.fetch_decimal_as_string is deprecated; see "Upgrading from 5.4.0".Decimal NaN and Infinity parameters are sent to the database instead of raisingSystemError; see above.decimal_mode = 'binary', a value the driver reports does not fit aDataError instead of being returned as a wrong number. Withnumeric(60, 45) cannot be read in binary mode. Use 'text', thesetinputsizes() with a (sqltype, size) tuple and no scale keeps the parameter's scale(SQL_DECIMAL, 18) no longer binds asdecimal(18, 18) and rejects values like 123.fast_executemany raises ProgrammingError for a Decimal or int with more than 38Decimal with more than 32767 digits after the decimal point raisesProgrammingError.statistics() and tablePrivileges() raise ValueError for a name longer than 32767execute() raises ValueError for a statement longer than 2147483647Decimal and UUID subclasses whose as_tuple() or bytes_le return invalid values raiseTypeError.connect() with a connection string that is not a str says "argument 1 must be a str".fast_executemany raised "Converting decimal loses precision" for any Decimalsetinputsizes() gives a size but no scale.locale.setlocale() is called after importing pyodbcdecimal_mode = 'text', the PostgreSQL default.setdecoding(pyodbc.SQL_WMETADATA, encoding='utf-8'), catalog functions such ascolumns() returned no rows.setDecimalSeparator() with a character that is special in regular expressions, such as ],decimal_mode = 'locale'.Connection.readvar_initsize of 1 or any odd number made fetching text fail or returnattrs_before key too large for an ODBC attribute ID set a different attribute; for2**40 + 102 set autocommit (102). Such keys now raise OverflowError.SystemError instead of the real exception:
UnicodeEncodeError)nextset() on a closed cursor (now ProgrammingError)Decimal column with a value that is not a Decimal, on some Python versions (nowTypeError)del pyodbc.lowercase or del pyodbc.native_uuid (the defaults are nownextset() returned an exception instead of raising it when the driver could not report theThese could be triggered by ordinary Python code:
fast_executemany cursor after an error while sending long parametersfast_executemany with Decimal NaN or Infinity, a Decimal with a very large exponent, orstr type or schema names, an empty first row, rows thatrange)del row[i] and del row.name, which now raise TypeErrorRow with an inconsistent column maptables() and columns() on a closed cursorfetchval() with rows_as_dictsconnect() with an encoding that cannot be encoded, or unusual attrs_before valuesConnection.set_attr() with values that cannot be encoded or are too largeTimeFromTicks() with a float or an out-of-range value (out-of-range values now raiseOverflowError)connect() after del pyodbc.pooling or del pyodbc.odbcversionReads or writes outside a buffer, or use of freed memory. Each needs an unusual setting,
value, driver, or subclass to reach. The review that found these and the crashes above is in
#1521, and what it found but 5.5.0 does not fix is in #1522.
Connection.readvar_initsize = 1, which let the driver write before the start of the buffergetinfo() strings, searchescape, error messages, or Cursor.messages,dataSources()Cursor.messages with a driver manager that uses a 4-byte SQLWCHARsetdecoding(pyodbc.SQL_WMETADATA, encoding='utf-8'), and namesstatistics() or tablePrivileges(), which the driverattrs_before string values, which the driver manager could read past the end ofbytearray parameter resized by another thread while a statement runs; bytearrayDecimal and UUID subclasses whose as_tuple() or bytes_le return invalid valuesDecimal with an extremely large negative exponent sent with execute()fast_executemany batches large enough to overflow the buffer sizesql_variant nested in a sql_variantpyodbc.native_uuid = True, which passed a length of the wrongdecimal_mode = 'binary' takes about 20% less time.fast_executemany negative scale fix.Full Changelog: 5.4.0...5.5.0
Your coding agent can read these notes before it upgrades. Set up the MCP server →
5.5.0: DECIMAL fixes for PostgreSQL, and crash and memory-safety fixes Latest
Latest
Compare
Version 5.4.0 has been released with wheels for Python 3.11 - 3.15
Version 5.4.0 has been released with wheels for Python 3.11 - 3.15
Connection.fetch_decimal_as_string = TrueCursor.rows_as_dicts) by @bkline in #1487Cursor.tablePrivileges()) by @bkline in #1463pyodbc.henv, Connection.hdbc, Cursor.hstmt) by @bkline in #1493connect(driver_completion=...)) by @bkline in #1488Connection.set_attr()) by @bkline in #1465dataSources(scope=...)) by @bkline in #1461Connection.readvar_initsize) by @bkline in #1490Connection.compat_diagrec_byte_length) by @bkline in #1464Full Changelog: 5.3.0...5.4.0
Version 5.4.0 has been released with wheels for Python 3.11 - 3.15
Connection.fetch_decimal_as_string = True
to restore the previous text-based behavior. By @bkline in https://github.com/mkleehammer/pyodbc/pull/1470
Cursor.rows_as_dicts) by @bkline in https://github.com/mkleehammer/pyodbc/pull/1487Cursor.tablePrivileges()) by @bkline in https://github.com/mkleehammer/pyodbc/pull/1463pyodbc.henv, Connection.hdbc, Cursor.hstmt) by @bkline in https://github.com/mkleehammer/pyodbc/pull/1493connect(driver_completion=...)) by @bkline in https://github.com/mkleehammer/pyodbc/pull/1488Connection.set_attr()) by @bkline in https://github.com/mkleehammer/pyodbc/pull/1465dataSources(scope=...)) by @bkline in https://github.com/mkleehammer/pyodbc/pull/1461Connection.readvar_initsize) by @bkline in https://github.com/mkleehammer/pyodbc/pull/1490Connection.compat_diagrec_byte_length) by @bkline in https://github.com/mkleehammer/pyodbc/pull/1464Full Changelog: https://github.com/mkleehammer/pyodbc/compare/5.3.0...5.4.0
If you followed the 5.4.0 notes and set Connection.fetch_decimal_as_string = True , it still works, but it now raises a FutureWarning , and it will be removed in 6.0. Use Connection.decimal_mode instead:
PostgreSQL: remove the line. The new default reads every value correctly. True selects the old text path, which cannot read NaN or Infinity, and False selects 'binary' , which reads them as 0.
Other databases: decimal_mode = 'locale' behaves exactly like fetch_decimal_as_string = True . If your driver never adds thousands separators, decimal_mode = 'text' is stricter and is not affected by the locale.
Reading fetch_decimal_as_string also raises FutureWarning . To silence it until you update your code:
warnings . filterwarnings ( "ignore" , message = ".*fetch_decimal_as_string" , category = FutureWarning )
Version 5.3.0 has been released with wheels for versions 3.9 - 3.14
Version 5.3.0 has been released with wheels for versions 3.9 - 3.14
HOMEBREW_PREFIX to locate Homebrew by @RA80533 in #1212Full Changelog: 5.2.0...5.3.0
Version 5.3.0 has been released with wheels for versions 3.9 - 3.14
HOMEBREW_PREFIX to locate Homebrew by @RA80533 in https://github.com/mkleehammer/pyodbc/pull/1212Full Changelog: https://github.com/mkleehammer/pyodbc/compare/5.2.0...5.3.0
Thanks to @keitherskine there are now wheels for 5.13. There are aiso a few bug fixes that were ready to go.
Thanks to @keitherskine there are now wheels for 5.13. There are aiso a few bug fixes that were ready to go.
Release 5.2.0 with wheels for Python 3.13
Compare
Mac M1 & M2 binaries are available going forward.
Mac M1 & M2 binaries are available going forward.
GitHub added new Mac ARM action runners which is what we use to build each release.
Thanks to @keitherskine who made all this happen. Not only did he write the original release code for all of the other versions, he jumped on the new Mac runner as soon as it was available.
I'd also like to thank the many people working through the Mac binary confusion, testing and providing work arounds until this runner was available: @Carreau @ndmlny-qs @jordantshaw @gabalafou @v-chojas and many others on the Issue.
If you are a Mac user, please let us know how this works for you.
This is a bug fix for 5.0.0 that restores the ability to pass bytes objects in the attrs_before parameter when connecting. This is often used for Azur
This is a bug fix for 5.0.0 that restores the ability to pass bytes objects in the attrs_before parameter when connecting. This is often used for Azure with a token. Issue #1289
This is the first 3.x only pyodbc release, supporting Python 3.8-3.12.
This is the first 3.x only pyodbc release, supporting Python 3.8-3.12.
The API is backwards compatible, so previous Python 3 products using pyodbc should not need any changes.
Please note that macOS ARM / Apple Silicon binary builds have been problematic due inconsistencies in the way unixODBC libraries can be installed. Please see the issues and discussions.
We're retrying macOS Apple Silicon wheels, for those with M1, M2, etc. chips. If you have one of these, please give this release a try so we know before the final 5.0.0 release in a few days.
This means you would not use Rosetta. Just install normally using pip install pyodbc==5.0.0b2. Don't use --no-binary.
For those wondering, the inability to supply these wheels has not been due to any pyodbc code issues. We use Github Actions to build all the different versions and it still doesn't have complete support for macOS Apple Silicon CI runners. At this time, only Intel is supported. However, we can cross-compile and generate ARM wheels on Intel, but we can't test them. That's why we need your help!
This is a beta release for the upcoming 5.0 that drops Python 2 and adds Python 3.12
Source and wheels for 5.0.0b1 is available on PyPI.
This beta restores fast_executemany, so it should be feature complete. If there are no serious issues reported, it will be released as 5.0.0 this week (before Python 3.12 is officially released).
This is a test release for the upcoming 5.0 that drops Python 2 and supports Python 3.12
Source and wheels for 5.0.0a2 is available on PyPI
Note that fastexecmany is not available in this release, but will be ported to the next.
Please give it a try and join the discussion here.
Prepare 5.0.0b3 release
Prepare 5.0.0b3 release
We're retrying macOS Apple Silicon wheels, for those with M1, M2, etc. chips. If you have one of these, please give this release a try so we know befo
We're retrying macOS Apple Silicon wheels, for those with M1, M2, etc. chips. If you have one of these, please give this release a try so we know before the final 5.0.0 release in a few days.
This means you would not use Rosetta. Just install normally using pip install pyodbc==5.0.0b2. Don't use --no-binary.
For those wondering, the inability to supply these wheels has not been due to any pyodbc code issues. We use Github Actions to build all the different versions and it still doesn't have complete support for macOS Apple Silicon CI runners. At this time, only Intel is supported. However, we can cross-compile and generate ARM wheels on Intel, but we can't test them. That's why we need your help!
This is a beta release for the upcoming 5.0 that drops Python 2 and adds Python 3.12
This is a beta release for the upcoming 5.0 that drops Python 2 and adds Python 3.12
Source and wheels for 5.0.0b1 is available on PyPI.
This beta restores fast_executemany, so it should be feature complete. If there are no serious issues reported, it will be released as 5.0.0 this week (before Python 3.12 is officially released).
This is a test release for the upcoming 5.0 that drops Python 2 and supports Python 3.12
This is a test release for the upcoming 5.0 that drops Python 2 and supports Python 3.12
Source and wheels for 5.0.0a2 is available on PyPI
Note that fastexecmany is not available in this release, but will be ported to the next.
Please give it a try and join the discussion here.
Version 4.0.38 had a serious bug in Row.__repr__ which could cause crashes (#1196 ). That version has been yanked from PyPI and replaced with this one
Version 4.0.38 had a serious bug in Row.repr which could cause crashes (#1196 ). That version has been yanked from PyPI and replaced with this one.
Version 5.0 is on its way and will drop support for Python 2. This release is a (hopefully final) bug fix release for the 4.x line.
Version 5.0 is on its way and will drop support for Python 2. This release is a (hopefully final) bug fix release for the 4.x line.
A big thanks to everyone involved:
Note that the 4.0.36 does not build with some versions of GCC. The 4.0.37 version is a fix for
this. Version 4.0.37 did not have the setup.py VERSION variable updated, so 4.0.38 is a fix for that!
This release provides Python 3.11 wheels, plus some other wheel fixes. A special thanks to @keitherskine for the wheel and automated build support tha
This release provides Python 3.11 wheels, plus some other wheel fixes. A special thanks to @keitherskine for the wheel and automated build support that makes this possible.
There is also an import memory fix when using fast_execute_many. Thanks to @gordthompson for that.
First, I want to say thank you very, very much to the people that setup and maintained the automated building of wheels: @keitherskine, @hugovk, and @
First, I want to say thank you very, very much to the people that setup and maintained the automated building of wheels: @keitherskine, @hugovk, and @abitrolly. This is the first release with wheels for Mac, completely thanks to them. It also saves me a huge amount of time since I no longer have to generate each wheel by hand on different systems.
Release highlights:
Nothing published for this version
Nothing published for this version
A backwards compatibility bug on Windows was causing "missing DLL" errors and not allowing pyodbc to be loaded (#663). This affected Python versions 3
A backwards compatibility bug on Windows was causing "missing DLL" errors and not allowing pyodbc to be loaded (#663). This affected Python versions 3.5+. This was due to building with a compiler that was newer than those used by the official Python builds. The newer Visual Studio 2019 introduced a dependency a new DLL which doesn't ship with Python, so pyodbc would fail to load unless something else had already installed the DLL.
Keith Erskine added a fix to check for overflow of integer and floating point parameters so that a proper Python exception is raised (#671).
Kieth and Gord Thompson also provided a bunch of improvements for unit tests.
Anatoli Babenia updated the readme with a badge for PyPI which provides a quick link to it. Very nice. PyPI should now also include the contents of the readme instead of just a single sentence thanks to a commit by Keith.
Nothing published for this version
Fix incorrect size calcation for Unicode characters
Fixes in this release:
Many thanks to everyone who provided these fixes. Merry Christmas.
Use int instead of bigint when possible (based on size of data) to work with drivers that don't support bigint at all. Thanks @gordthompson and @v-mak
This is mostly a bug fix release.
This is mostly a bug fix release.
Additionally, thanks @gordthompson for both adding get_output_converter (#496) and for updating the SQL Server tests to properly bypass issues not supported with the FreeTDS driver.
Due to #506, I recommend upgrading from 4.0.25 where the issue was introduced.
Many thanks to the community for this release:
Many thanks to the community for this release:
test_tvp in the SQL Server unit tests.I cleaned up SQLite unit tests which were out of date and upgraded deprecated unittest methods from all tests. v-chojas made a fix to SQL Server test_…
This is a bug fix release with fixes from lots of contributors:
Some changes in 4.0.22 to integrate the old parameter binding and the new executemany array binding have not handled Unicode in all cases. The integra
Some changes in 4.0.22 to integrate the old parameter binding and the new executemany array binding have not handled Unicode in all cases. The integration has been reverted to ensure pyodbc is as stable as possible.
If you had issues with 4.0.22, please try 4.0.23.
Nothing published for this version
This is a minor release that adds:
This is a minor release that adds:
Nothing published for this version
Sorry everyone - I left a debug printf statement in the 4.0.18 code. Please use this instead. I'm reproducing the 4.0.18 tag release notes here:
Sorry everyone - I left a debug printf statement in the 4.0.18 code. Please use this instead. I'm reproducing the 4.0.18 tag release notes here:
This is a primarily a fix patch, thought it does contain one new feature that is turned off by default:
The feature is an optimized Cursor.executemany that binds parameters into an array to drastically reduce network round trips. This can be a major speedup, but this preliminary version is turned off by default because it can only be used with drivers that use UCS-2 exclusively and that properly deal with the ODBC numeric structure. Right now I would recommend only using this with SQL Server on Windows. This feature will be tweaked in the near future to support as many drivers as possible and to use the configured encodings.
None passed in for optional keyword parameters such as Cursor.columns('t1', schema=None).This is a primarily a fix patch, thought it does contain one new feature that is turned off by default:
This is a primarily a fix patch, thought it does contain one new feature that is turned off by default:
The feature is an optimized Cursor.executemany that binds parameters into an array to drastically reduce network round trips. This can be a major speedup, but this preliminary version is turned off by default because it can only be used with drivers that use UCS-2 exclusively and that properly deal with the ODBC numeric structure. Right now I would recommend only using this with SQL Server on Windows. This feature will be tweaked in the near future to support as many drivers as possible and to use the configured encodings.
None passed in for optional keyword parameters such as Cursor.columns('t1', schema=None).Nothing published for this version
This release adds support for subinterpreters, which fixes crashes in systems like mod_wsgi that run multiple Python interpreters in the same process.
This release adds support for subinterpreters, which fixes crashes in systems like mod_wsgi that run multiple Python interpreters in the same process.
Upgrade ASAP. Previous 4.x versions could cause any parameters passed to SQL statements to live forever by incrementing their reference count.
Upgrade ASAP. Previous 4.x versions could cause any parameters passed to SQL statements to live forever by incrementing their reference count.
Fix for #206 where Cursor.fetchall() fails due to a possible bug in PyCodec_Encode. Encoding works correctly but it sets an invalid exception which fe
Fix for #206 where Cursor.fetchall() fails due to a possible bug in PyCodec_Encode. Encoding works correctly but it sets an invalid exception which fetchall() detects.
Same as 4.0.12, but fix building for Python 2.7
Same as 4.0.12, but fix building for Python 2.7
The new pyodbc.drivers() implementation buffer was too small, so names would get truncated.
The new pyodbc.drivers() implementation buffer was too small, so names would get truncated.
Also fixed a potential double-decrement during import, but did not have a case where it crashed.
Ignore driver-reported max varchar if <=255. Some drivers like FileMaker return -1, etc., which caused a hang when writing.
Added support for reading IBM DB/2 columns as Unicode text.
Added support for reading IBM DB/2 columns as Unicode text.
Merged in pull request that adds a localhost homebrew directory to the include paths on macOS. Thanks @sgivens0
Merged in a long-neglected pull request that adds pyodbc.drivers(). Thanks @sergiodlc
Nothing published for this version
Accept UUID objects as parameters. If pyodbc.native_uuid is True, return SQL_GUID columns as UUID objects. If False, the default for backwards compati
Accept UUID objects as parameters. If pyodbc.native_uuid is True, return SQL_GUID columns as UUID objects. If False, the default for backwards compatibility, return them as Unicode strings.
Issue #84 Previously all Python 3 longs were sent via SQL_BIGINT but Access does not support this so now SQL_INTEGER is used when possible. This is al
Issue #84 Previously all Python 3 longs were sent via SQL_BIGINT but Access does not support this so now SQL_INTEGER is used when possible. This is also a nice optimization for other drivers.
Also fixed #195 - Python 3 text and Python 2 unicode was always passed as SQL_WVARCHAR even if the encoding was set to something like UTF-8 that should be SQL_VARCHAR.
Recently a change was made to use SQLDescribeColW so that Unicode column names could be retrieved properly. Unfortunately this uncovered some weirdnes
Recently a change was made to use SQLDescribeColW so that Unicode column names could be retrieved properly. Unfortunately this uncovered some weirdness with some drivers, this time Teradata.
I'm not sure if the issue is iODBC (which Apple doesn't ship anymore) is using a 4-byte SQLWCHAR or if Teradata is returning UCS4/UTF-32LE for column names in SQLDescribeColW. Either way I've added a hack that assumes 4-byte chars if the decoding for SQL_WMETADATA (a pyodbc specific constant) is set to any of the UTF-32 encodings. The encoding is then actually used.
cnxn.setdecoding(pyodbc.SQL_WMETADATA, encoding='utf-32le')
Fixes #194
Nothing published for this version
Fix decoding of Cursor.description column names. Fixes #190 - The issue was a column alias with an i with acute which caused an error. pyodbc now (1)
Fix decoding of Cursor.description column names. Fixes #190 - The issue was a column alias with an i with acute which caused an error. pyodbc now (1) uses the Unicode version of SQLDescribeColumn and (2) uses the configured SQL_C_WCHAR encoding. I've added SQL Server test decode_meta for this.
When a connection is used in a with clause (as a context manager), the connection has always been committed if successful. However, when an exception is raised it now issues a specific rollback. In the past neither was performed if an exception was raised.
Nothing published for this version
Important fixes for reading decimal/numeric columns, gettypeinfo, an error when reading an empty string.
Important fixes for reading decimal/numeric columns, gettypeinfo, an error when reading an empty string.
This is a doc-only update to replace 4.0.0 which I removed from PyPI (pip). This should be 100% compatible with 4.0.0.
This is a doc-only update to replace 4.0.0 which I removed from PyPI (pip). This should be 100% compatible with 4.0.0.
I was attempting to replace the source tarball for 4.0.0 but that is apparently not allowed. It would have been nice to know that before it let me delete it ;)
You should upgrade to 4.0.2, however, for some important bug fixes.
Unicode handling has been rewritten for correctness. Make _sure_ you read the Unicode documentation if you have any issues.
Unicode handling has been rewritten for correctness. Make sure you read the Unicode documentation if you have any issues.
MySQL and PostgreSQL users: You will probably need to add a couple of lines of configuration. See the Unicode documentation!
WARNING: The source code for this version is not available on PyPI. Please upgrade to 4.0.2.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.