Added a work-around for a regression in Python 2.7.4
that results in a segfault when exiting Python after loading mxODBC.
The regression will be fixed in Python 2.7.5, but we don't want to
expose our users to segfaults, so added a work-around.
Fixes:
Fixed a bugglet which caused connection.__members__ to no longer list connection attributes.
Backported the new .cursortype attribute from the upcoming mxODBC 3.3.
The new attribute allows easily adjusting and inspecting the ODBC cursor type to be used for an mxODBC cursor object.
The reason for this unusual backport and inclusion in a
patch level release is that we found a serious performance issue with MS
SQL Server when using it with mxODBC 3.2 (see below). This needed to be
addressed immediately.
Driver Compatibility:
MS SQL Server performance can now be much enhanced,
and increased to levels beyond that of mxODBC 3.1 and previous
releases, by adjusting the default cursor type to forward-only cursors:
connection = mx.ODBC.Windows.DriverConnect(...) connection.cursortype = mx.ODBC.Windows.SQL.CURSOR_FORWARD_ONLY # Cursors created on this connection will then default to forward # only cursors, instead of the mxODBC 3.2 default for SQL Server # of using static cursors cursor = connection.cursor()
The performance increase compared to mxODBC 3.2.1 is enormous: from 2-3x faster executes/fetches for average queries, up to 300x faster for simple cases.
In mxODBC 3.3, we will switch to using forward-only cursors per default for all database backends.
IBM DB2 can benefit from the same performance enhancements using forward-only cursors.
The effect is a lot smaller, but still noticeable: up to 2x faster executes/fetches with forward-only cursors, compared to mxODBC 3.2.1.
Added documentation to explain the different cursor types, compatibility with different database backends and effects on performance.
Fixes:
Fixed a problem with using mxODBC cursors as context managers: these worked fine in Python 2.6, but had stopped working in Python 2.7 due to changes in the Python internals.
Switched to unixODBC 2.3.1+ API: mxODBC is now compiled
against unixODBC 2.3.1, which finally removes the problems with the ABI
change between 2.2 and 2.3 by switching to a new library version
(libodbc.so.2).
mxODBC connection objects can now be used as context managers to implicitly commit/rollback transactions.
mxODBC cursor objects can now be used as context managers to implicitly close the cursor when leaving the block (regardless of whether an exception was raised or not)
mxODBC added support for adjustable .paramstyles. Both 'qmark' (default) and 'named'
styles are supported and can be set on connections and cursors. The
'named' style allows easier porting of e.g. Oracle native interface code
to mxODBC.
mxODBC now supports a writable connection.autocommit attribute to easily turn on/off the connection's auto commit mode.
mxODBC added support for adjustable TIMESTAMP precision via the new connection/cursor.timestampresolution attribute.
mxODBC will round to nearest nanosecond fraction instead of
truncating the value. This will result in fewer conversion errors due to
floating point second values.
mxODBC's connect APIs Connect() and DriverConnect() support
setting connection options prior to connecting to the database via a new
connection_options parameter. This allows enabling e.g. the MARS feature in SQL Server Native Client.
The connection.cursor() constructor now has a new cursor_options parameters which allows configuring the cursor with a set of cursor options.
The .scroll() method supports far more ODBC drivers than before.
The .scroll() method no longer needs a working .rownumber and .rowcount implementation from the ODBC drivers (in most cases)
Updated the SQL lookup object to include more ODBC SQL parameter codes, including special ones for SQL Server and IBM DB2.
Added DataDirect specific SQL lookup object attributes.
mx.ODBC.Manager will now prefer unixODBC over iODBC.
Previous mxODBC releases used the order iODBC, unixODBC, DataDirect
when looking for a suitable ODBC manager on Unix platforms. unixODBC is
more widely supported nowadays and provides better Unicode support than
iODBC.
Driver Compatibility:
Added work-around for Oracle Instance Client to prevent use
of direct execution. cursor.executedirect() will still work, but won't
actually use direct execution with the Oracle driver.
Added work-around for Oracle Instant Client to prevent segfaults
in the driver when querying the cursor.rowcount or cursor.rownumber.
Added check to make sure that Python type binding mode is not used
with Oracle Instance Client as this can cause segfaults with the driver
and generally doesn't work.
Added a work-around to have the IBM DB2 driver return correct .rowcount values.
Improved Sybase ASE driver compatibility: this only supports Python type binding, which is now enabled per default.
Added work-around for PostgreSQL driver, which doesn't support scrollable cursors.
Add support for MS SQL Server ODBC Driver 1.0 for Linux to mxODBC
Improved compatibility of the mxODBC native Unicode string format
handling with Unix ODBC drivers when running UCS4 builds of Python.
mxODBC 3.2 now always uses direct execution with the FreeTDS ODBC driver. This results in better compatibility with SQL Server and faster execution across the board.
Add work-around to have FreeTDS work with 64-bit integers outside the 32-bit signed integer range.
Fixed linker error in FreeTDS subpackage. Note that this is not supported; please use the unixODBC/iODBC packages instead.
FreeTDS' .rowcount attribute gave misleading values for SELECTs.
This now always returns -1 (until they hopefully fix the driver to
return usable data).
Fixes:
Better error message in case .executemany() parameters is found not to be a sequence.
Enhanced error message when passing non-sequence items in a parameters list to cursor.executemany()
Fixed a small memory leak in the mxODBC connection constructor.
Added back mx.ODBC.unixODBC packages for the Mac OS X PPC and i386 builds.
Fixed a problem where the mx.ODBC.DataDirect package could load an iODBC shared lib. This will now result in an ImportError.
Added note about Sybase ASE 15 ODBC driver and using NULL with SQL_CHAR columns
Fix a rare case of truncation of Unicode data when working with
ODBC drivers/manager that use sizeof(SQLWCHAR) == 1 (standard is 2 or
4).
Misc:
mxODBC now uses PyObject_MALLOC() for memory allocation which should make memory allocation a little faster in a few places.
Added egenix-mx-base dependency to the mxODBC egg archives. Note
that relying on this to automatically install egenix-mx-base is not a
good idea, since easy_install will download and install the source
archive, so a compiler is needed and the compilation can easily fail.
Fixed a compatibility problem with Python 2.7's distutils that was introduced in Python 2.7.3
Improved compatibility of the mxODBC native Unicode string format
handling with Unix ODBC drivers when running UCS4 builds of Python.
This
allows using the NVARCHAR and NCHAR types of SQL Server with the new MS
SQL Server Native Client for Linux with UCS4 Python builds. UCS2 Python
builds don't exhibit this issue. The new driver has proven to be much more feature complete than the FreeTDS ODBC driver, so it's definitely worth a try.
Note that the MS driver currently has an issue with Unicode connection
strings which causes stack corruption. Please don't use Unicode
connection strings with the MS
SQL Server Native Client for Linux driver, since there's no way
we can work around this problem: we only know the type of driver after
connection and then it's already too late.
Added Python 2.7 support and builds for all platforms.
Added workarounds for Oracle Instant Client ODBC driver. This is now fully supported by mxODBC.
We found that cursor.executedirect() is not supported by the Oracle Instance Client ODBC driver. Please use .execute() instead.
Updated support for the latest IBM DB2 9.7 ODBC drivers.
Enhanced compatibility of mxODBC with the Sybase ASE 15 ODBC drivers on Unix.
mxODBC will now accept datetime.date objects for
datetime/timestamp columns in SQL type binding mode by using 00:00:00
as time value. This is useful when working with MS SQL Server 2000 and 2005 which don't support DATE columns.
Added support for Netezza to mxODBC.
Added new ODBC manager subpackage mx.ODBC.DataDirect for the DataDirect ODBC manager. This is currently only available on 32-bit and 64-bit Linux platforms.
mxODBC now supports the Teradata database via the new mx.ODBC.DataDirect subpackage.
mxODBC now supports unixODBC 2.3.0 and later on 64-bit platforms. Previous versions are no longer supported.
Added much improved documentation on how to connect to various popular databases, including tips & tricks for each database/driver.
mxODBC can now be licensed to single database backends (mxODBC Standard Edition Licenses), reducing licensing costs.
We have simplified the licensing terms for multi-core processors
and virtual machines. In most cases, this results in greatly reduced
licensing costs.
mxODBC now clearly separates ODBC 2.x and ODBC 3.x support for
date/time types. This improves compatibility with a few ODBC drivers,
notably the one for Netezza.
mxODBC now always uses ODBC 3.x APIs where available instead of ODBC2 APIs.
mxODBC now also accepts Python 2.7 memoryview object where buffer objects were already supported. This is useful when writing code in preparation for the transition to Python 3.x.
mxODBC now uses the read data buffer interface for buffer objects,
rather than the character data interface, in order to enhance support
for binary buffer data objects.
Added a work-around for unixODBC issuing warnings instead of errors when not finding ODBC driver shared libraries.
Added a direct parameter to .execute().
Turned .execute(), .executemany() and .executedirect() into keyword parameter methods.
Setting .bindmethod = BIND_USING_PYTHONTYPE will now have mxODBC
ignore the SQL type information completely. This makes it easier to
work with drivers such as the SQL Server Native Client which have a few client-side limitations that do not appear to be present on the server-side.
Changed the license
module name to mxodbc_license.py, so that it can be installed as
top-level module anywhere on the sys.path. Note that installing it in
mx/ODBC/ will no longer work.
mxODBC cursors and connection objects now provide a new .warningformat attribute which allows easily turning SQL warnings into Python warnings or completely ignoring them.
Added native support for BIGINT (both signed and unsigned) which avoids strings conversions if supported by the platform.
Added support for non-standard SQLWCHAR types in order to better support drivers and manager on Unix platforms.
mxODBC now allows choosing between the Unicode and ANSI ODBC driver APIs of supporting ODBC drivers at connection time.
All catalog methods now support Unicode parameters as well as strings parameters.
Added support for adjusting the way catalog methods interpret their parameters (as identifiers or as search patterns).
Catalog methods now check for arguments required by the ODBC API
standard, rather than letting the ODBC manager or driver raise an error.
Added new cursor.getcolattribute() method to allow access to result set column meta-data beyond what is already available via cursor.description. See http://msdn.microsoft.com/en-us/library/ms713558.aspx for
details on what kind of information is available. Many drivers extend
this list with additional database specific information.
Renamed "mxODBC Distribution" to "mxODBC for Python".
mxODBC now uses PyObject_MALLOC() for memory allocation which should make memory allocation a little faster in a few places.
Improved the documentation of the catalog methods and included hints for their use.
cursor.execute() will no longer treat lists passed in as
parameters as emulation for cursor.executemany(). This was a Python
DB-API 1.0 related feature which was kept for backwards compatibility,
but has recently caused some confusion among new users. If you want to
run multiple parameter sets against a single SQL command (e.g. for
inserts), please use cursor.executemany().
Added a new section on the ODBC configuration files and environment variables to the documentation.
mxODBC will now be more careful when trying to determine the row
position of the first row in the result set. This enhances
compatibility with the SQL Server 2000 drivers and possibly others as well.
mx.ODBC.Manager will now use the mx.ODBC.DataDirect package if no other ODBC managers are found.
Fixed a bug that prevented .prepare() from accepting Unicode strings.
Fixed problem with passing Unicode arguments to catalog methods.
mx.ODBC.Misc.test now provides an option --ignore-warnings
Fixed test script to not report bogus memory leaks.
The mxODBC test script no longer expects the database to return rows in the same order as they were inserted into the tables.
Changed
cursor.statistics() to default to accuracy=SQL.QUICK, since the
parameter was deprecated in ODBC3 and SQL.ENSURE value doesn't comply
to the Open Group standards.
mxODBC no longer supports being built without Unicode support.
Changes from 3.0.3 to 3.0.4
Fixed a problem with the Mac OS X builds not working on Intel Macs.
Added platform detection code to the prebuilt archives so that
mismatches between the downloaded version and the installation platform
are not reported to the user instead of causing a compilation errors.
Changes from 3.0.2 to 3.0.3
Fixed a bug in print_resultset() due to a missing import in one of the modules.
Added native iterator support to mxODBC cursor objects.
Added a note to the documentation on hidden module dependencies when wrapping mxODBC into applications using py2exe.
Fixed issues with prebuilt Mac OS X builds not installing on some Mac OS X versions.
Changes from 3.0.1 to 3.0.2
mxODBC now has better support for using TEXT and VARCHAR
columns with binary data, esp. for database drivers which require the
Python type binding mode, such as the FreeTDS ODBC driver.
Fixed a problem with the prebuilt packages not installing on Mac OS X.
Corrected version number of mx.ODBC to show '3.0.2' instead of '2.1.0'
Added work-around for crashing MySQL ODBC 3.51.20 driver
Added work-around for Informix ODBC driver complaining about timestamp formats
mxODBC now includes the license verification module dependencies, so
you no longer have to add them manually when using e.g. py2exe
Added a note to the documentation on hidden module dependencies when wrapping mxODBC into applications using py2exe.
Added work-around for SQL Server 2005 to be able to retrieve >1MB
Unicode data when running mxODBC in UNICODE_STRINGFORMAT string format
mode.
Enhanced the .stringformat documentation to more clearly state how the conversion processes work.
mxODBC .stringformat set to UNICODE_STRINGFORMAT did not convert
Unicode to 8-bit strings when run in Python type binding mode.
Added Python datetime support on Python 2.3
Added Python 2.6 support on Windows (using VC9)
mxSetup prebuilt archives no longer need to use "... build --skip ..."
to skip the build process. The build command is now smart enough to
detect, check and automatically use a build pickle and the prebuilt
format.
Fixed a problem in mxSetup that caused the uninstall
command not to work with prebuilt packages. Thanks to Wouter van
Atteveldt for pointing out the problem.
Changes from 3.0.0 to 3.0.1
Fixed a bug in the stringformat setting that could cause
the stringformat setting not to affect the SQL type used in binding
parameters
Fixed a bug in the way binding sets the length information for Unicode data when running in Python type mode
Use
the VAR-variants of character SQL types in favor of the plain SQL type
codes to work-around issues with padding in some drivers (notably the
SQL Server ODBC driver)
Added better documentation for cursor.errorhandler and how this inherits from connection.errorhandler
Added cursor.errorhandler example to the documentation
Updated the documentation of the SQL types used in both SQL type and Python type binding mode
Changes from 2.0.7 to 3.0.0
Added cursor.callproc() with support for input parameters.
Added cursor.nextset().
Added aliasing support for platform specific ODBC managers:
mx.ODBC.Manager is aliased to the most commonly used ODBC manager for
the platform running mxODBC (the Windows subpackage on Windows, iODBC
on all other platforms).
Added new .messages list attribute to both connection and
cursor objects. All error and warning messages (tuples (exception
class, exception value)) will be appended to these lists. The lists are
automatically cleared by most cursor and connection methods except the
fetch methods and the connection info/option methods.
Changed the type names and repr() output of
connections and cursor type objects to better reflect the used
interface (e.g on Windows the type name will be "mx.ODBC.Windows
cursor" rather than just "mxODBC Cursor").
Rearranged the code for fetching SMALLINTs, TINYINTs and
BITs to do the fetching using a C short rather than a C long. Some ODBC
drivers are buggy in that they fail to correctly convert these small
integers to longs.
Added documentation of the exception value layout.
Added all exception objects (including the Warning exception) as
attributes to the connection objects. This enables writing code which
can catch exceptions independent of the mxODBC subpackage being used.
Added some support for CYGWIN. Thanks to Steve Holden for suggesting the needed tweaks.
Added cursor.connection attribute which allows accessing the Connection object used by the cursor.
Fixed parameter input binding to not change the SQL type due to None
parameters after having already bound a different type. This should
solve the problem with some Oracle drivers complaining about this.
Added cursor.rownumber providing a way to query the current result set position of the cursor.
Added cursor.getcursoroption() which can be used to query low-level details about the cursor such as timeouts etc.
Added cursor.scroll() which enables result set scrolling.
cursor.executemany() now accepts sequences of sequences as required by API 2.0.
Changed: cursor.execute() no longer accepts list of tuples as parameter. Use cursor.executemany() instead.
The new SAP DB support is now official.
Added extensive documentation to the cursor catalog methods.
Changed the cursor.freeset() method name to cursor.flush(). The old name is still available for backward compatibility.
Fixed bug in DataSources() work-around for iODBC which caused the DSN names to be truncated to two characters.
Changed
the SQL types used for passing input data to the ODBC driver using
.executeXXX() methods in Python type binding mode. Instead of
defaulting to SQL_CHAR and SQL_BINARY, these now use the SQL types
SQL_VARCHAR, SQL_VARBINARY.
Added better support for Python type bindings: strings
are now analyzed for binary content and then bound in binary mode if
needed.
Added new connection attributes .dbms_name, .dbms_version, .driver_name, .driver_version.
Added new cursor methods .next() and .__iter__() which enable cursors to be used as iterators in Python 2.2.
Changed
quite a few SQLSTATE to exception class mappings and added new mappings
for ODBC 3.x. If you need to force usage of other mappings, please
assign these mappings to the modules scope dictionary errorclass.
Added user definable error handlers as defined in the DB API 2.0 extensions.
Changed
the Windows source files from using the .cpp extension to the .c
extension. This should avoid confusion with non-VC compilers since
mxODBC does not include any C++ code. It also works nice with
distutils.
Added more SQL_* symbols. The list now includes all
integer symbols from ODBC 3.51 and many database specific extensions
(including IBM DB2 extensions and MS SQL Server extensions).
Added new experimental subpackage mx.ODBC.FreeTDS which
allows connecting to MS SQL Server from Unix. This is still far from
even being called alpha due to the current lack of implementation
support of many important ODBC APIs in the FreeTDS ODBC driver.
Changed: Exception classes of subpackages are now
identical to the base classes defined in mx.ODBC.Error. They are no
longer defined on a per subpackage basis. This should make writing
cross-database applications a little easier.
Updated the Solid subpackage from Solid 2.2 to Solid
3.52. This update involved several small tweaks to make the Solid ODBC
driver happy.
Fixed a bug in the code for fetching Unicode BLOBs which caused NUL characters to be inserted into the resulting string.
Made the BLOB fetching code a little smarter to work around bugs in
ODBC drivers which don't 0-terminate character data hunks (this
resulted in missing bytes at 1024 byte boundaries).
Strings in Python binding mode will now bind as
SQL_VARBINARY/SQL_LONGVARBINARY if necessary. Wrap them in buffer
objects to always force binding them as VARBINARY data fields. This
fixes compatibility problems with some ODBC drivers which don't support
SQL type binding.
Integrated mxLicenseManager. In order for mxODBC to work,
a license.py file must be present in the mx/ODBC/ directory of the
package.
Added work-around for binding large data chunks in Python
binding mode. This solves a problem with EasySoft's Oracle ODBC driver.
Unfortunately, the work-around oes not work for CLOB columns: if you
pass in data with less than 256 bytes, an error is raised by the
driver.
Added work-around for EasySoft driver to always bind using the SQL_LONGxxx types.
Fixed a typo in the FETCH_UNKNOWN_TYPES_AS_STRINGS and SEND_UNKNOWN_TYPES_AS_STRINGS compile time options.
Added work-around for bug in MS Access ODBC driver to always send at
least sqllen=1 for bound parameters. It rejects parameters bound with
sqllen=0 and issues an HY104 error.
Added statistics() API which allows checking the number of currently open connections and cursors.
Ported to Python 2.5 and tested with that version.
Fixed
bugglet in mxODBC_UnicodeAsSQLWCHAR() where two parameters were
switched, causing the buffer length to appear as string length.
Changed HY019 error mapping from InterfaceError to ProgrammingError: MS SQL Server returns this for integer overflow errors
PyNumber_Int()
can return a Python long in Python 2.5 and later. Fixed mxODBC to deal
with this case, so that binding to integer columns continues to work
even if you pass in a Python long and the database requested an integer.
Fixed
64-bit integer binding: on 64-bit platforms, SQL_C_SLONG does not map
to a 64-bit type, but a 32-bit type (weird, but true, and caused by the
fact that Win64 works this way: longs on Win64 only have 32 bits).
Added test cases for BYTEA (PostgreSQL)
Added mapping of 22P06 to Warning to make the PostgreSQL driver work with BYTEA and binary data
Added
test cases for NTEXT and NCHAR to the test suite. These two column data
types are available in SQL Server and provide native Unicode storage.
Added work-around for bug in iODBC on 64-bit platforms: it sends 0xFFFFFFFF instead of -1 for NULL data columns
Added support for passing Unicode commands to .executeXXX().
Added optional support for the new Decimal type introduced in Python 2.4; recognize Decimal types on input
Added
optional support for the datetime types introduced in Python 2.3; using
the Python interface for Python 2.3 and the new C interface in Python
2.4; recognize datetime types on input
mxODBC now no longer
request the .rowcount per default after each .executeXXX() call - some
databases are very slow when it comes to finding out the true number of
rows in the result set
Increased the default value of
DEFAULT_LONG_SIZE to e.g. 32000 - this can make a big difference since
it avoids network roundtrips in networked setup
Changes from 2.0.6 to 2.0.7:
Added Python 2.4 support.
Added UCS2 and UCS4 builds of the package.
Changes from 2.0.5 to 2.0.6:
Added DB-API attribute threadsafety.
Added Python 2.3 support.
Changes from 2.0.4 to 2.0.5:
Fixed a bug in the native Unicode handling code for long
object columns. mxODBC now also supports reading and writing Unicode to
and from longchar and ntext columns for MS SQL Server.
Changes from 2.0.3 to 2.0.4:
Enhanced compatiblity to Unicode-aware ODBC drivers such
as the latest MS SQL Server and MS Access ODBC drivers. Exchanging
native Unicode data with these drivers is now supported for input
parameters and output data retrieved using the .fetchXXX() APIs.
Catalog methods and other APIs do not support Unicode.
Rearranged the code for fetching SMALLINTs, TINYINTs and
BITs to do the fetching using a C short rather than a C long. Some ODBC
drivers are buggy in that they fail to correctly convert these small
integers to longs.
Changes from 2.0.2 to 2.0.3:
Enhanced test script (mx.ODBC.Misc.test) to show available data sources for ODBC managers before connecting.
Added docs about usage of mxODBC with Thomas Heller's py2exe.
Added work-around for some ODBC drivers which don't initialize the
buffers for small integers correctly. This lead to wrong results when
reading data from SMALLINT columns with these drivers. Writing to these
column types did not pose a problem. Thanks to Villiam Manera for
bringing this to my attention again (mxODBC already included a hint to
the problem, but no actual fix for it).
Changes from 2.0.1 to 2.0.2:
Added a new section on stored procedures to the docs.
Thanks to Jim Vickroy for finding out about the usage of PRINT in MS
SQL Server stored procedures.
Tested under Python 2.1.
Changes from 2.0.0 to 2.0.1:
Fixed the documentation w/r to debugging builds. The
default configuration does contain the debugging code. See the
debugging section for details on how to build a debugging version.
Changed handling of warnings during database connect:
warnings will no longer be reported as exceptions. This should allow
connects to e.g. MS SQL Server to work without having to recompile
mxODBC on Windows.
Fixed a bug in the handling of direct execution (.executedirect()). Input parameters passed to .executedirect() will be bound using Python bindings.
Reverted a change
introduced in 2.0.0 which prevered the ODBC 3.5 data types for
date/time values over the old ones. The MS ODBC manager has massive
problems with these, which cause all queries involving date/time
columns to fail. mxODBC 2.0.1 will no again use the old type codes,
which work fine with all ODBC drivers/managers.
Added experimental SAP DB support as new subpackage mx.ODBC.SAPDB.