summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/mssql/pyodbc.py
Commit message (Collapse)AuthorAgeFilesLines
* Merge "Add autocommit documentation for Azure SQL DW"mike bayer2021-10-061-3/+42
|\
| * Add autocommit documentation for Azure SQL DWGord Thompson2021-09-281-3/+42
| | | | | | | | | | Fixes: #7065 Change-Id: I3666e16f9a8c47f9784ea11f38972cda6b08c146
* | organize datetime types for correct implsMike Bayer2021-10-011-2/+6
|/ | | | | | | | | | | | | | Fixed bug in SQL Server ``DATETIMEOFFSET`` where the ODBC implementation would not generate the correct DDL, for cases where the type were converted using the ``dialect.type_descriptor()`` method, the usage of which is illustrated in some documented examples for :class:`.TypeDecorator`, though not necessary for most datatypes. Regression was introduced by :ticket:`6366`. As part of this change, the full list of SQL Server date types have been amended to return a "dialect impl" that generates the same DDL name as the supertype. Fixes: #7129 Change-Id: I7d9bea54c0c38e16d1a6ad978cca996006a1b624
* Replace all http:// links to https://Federico Caselli2021-07-041-4/+4
| | | | | | Also replace http://pypi.python.org/pypi with https://pypi.org/project Change-Id: I84b5005c39969a82140706472989f2a30b0c7685
* fix typo in"Connecting to databases with access tokens" (#6432)Katsuyuki Sakai2021-05-251-1/+1
|
* Pass all datetime values to pyodbc for timezone-naive columnMike Bayer2021-04-261-2/+8
| | | | | | | | | | | | Fixed regression caused by :ticket:`6306` which added support for ``DateTime(timezone=True)``, where the previous behavior of the pyodbc driver of implicitly dropping the tzinfo from a timezone-aware date when INSERTing into a timezone-naive DATETIME column were lost, leading to a SQL Server error when inserting timezone-aware datetime objects into timezone-native database columns. Fixes: #6366 Change-Id: Id7821de13d75ede27f2165b37277a7223468dfa4
* Add DateTime(timezone=True) support to mssqlGord Thompson2021-04-201-2/+11
| | | | | | | | | | The :paramref:`_types.DateTime.timezone` parameter when set to ``True`` will now make use of the ``DATETIMEOFFSET`` column type with SQL Server when used to emit DDL, rather than ``DATETIME`` where the flag was silently ignored. Fixes: #6306 Change-Id: I4def8337046e8c190d424fa4a259ab24d5f9039e
* Default caching to opt-out for 3rd party dialectsMike Bayer2021-04-011-0/+1
| | | | | | | | | | | | | | | | | | | Added a new flag to the :class:`_engine.Dialect` class called :attr:`_engine.Dialect.supports_statement_cache`. This flag now needs to be present directly on a dialect class in order for SQLAlchemy's :ref:`query cache <sql_caching>` to take effect for that dialect. The rationale is based on discovered issues such as :ticket:`6173` revealing that dialects which hardcode literal values from the compiled statement, often the numerical parameters used for LIMIT / OFFSET, will not be compatible with caching until these dialects are revised to use the parameters present in the statement only. For third party dialects where this flag is not applied, the SQL logging will show the message "dialect does not support caching", indicating the dialect should seek to apply this flag once they have verified that no per-statement literal values are being rendered within the compilation phase. Fixes: #6184 Change-Id: I6fd5b5d94200458d4cb0e14f2f556dbc25e27e22
* Merge "Add documentation for connecting to Azure SQL instances with managed ↵mike bayer2021-03-191-8/+69
|\ | | | | | | identities"
| * Add documentation for connecting to Azure SQL instances with managed identitiesAlex Lowe2021-03-181-9/+70
| | | | | | | | | | | | | | | | | | Fixes: #6031 Closes: #6032 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6032 Pull-request-sha: 00abfffd198a4c0e81bb5d15219dd4e40670ce94 Change-Id: Id67b21e6d2cc93f88d78e291e3bc8f87463377a6
* | Turn off pyodbc setinputsizes() by defaultMike Bayer2021-03-161-1/+18
|/ | | | | | | | | | | | | | Fixed regression where a new setinputsizes() API that's available for pyodbc was enabled, which is apparently incompatible with pyodbc's fast_executemany() mode in the absence of more accurate typing information, which as of yet is not fully implemented or tested. The pyodbc dialect and connector has been modified so that setinputsizes() is not used at all unless the parameter ``use_setinputsizes`` is passed to the dialect, e.g. via :func:`_sa.create_engine`, at which point its behavior can be customized using the :meth:`.DialectEvents.do_setinputsizes` hook. Fixes: #6058 Change-Id: I99c2be3a5cd76fc3e490d10865292ed85ffc23ae
* Add missing colon before code block in docsFederico Caselli2021-02-261-1/+1
| | | | Change-Id: Iee0ec6906fe21674a16c20dfd267468ebfe39c3f
* mssql+pyodbc specify ampersand separatorGord Thompson2021-02-241-1/+10
| | | | | | | Specify that ampersand (not semicolon) must be used to separate additional keyword arguments in hostname connections. Change-Id: Id5b3276e6da8d42f5384e3cc4f5272f6e20aa61c
* happy new yearMike Bayer2021-01-041-1/+1
| | | | Change-Id: Ic5bb19ca8be3cb47c95a0d3315d84cb484bac47c
* Add SQL Server 01000 disconnectMike Bayer2020-10-141-3/+4
| | | | | Fixes: #5646 Change-Id: I25fcba7cf866871f1232b586e7e604162bd8cc43
* Add support for Azure authentication optionsGord Thompson2020-09-171-1/+2
| | | | | Fixes: #5592 Change-Id: I0688e5ea0fc6b01a0b72f397daea8f57a2ec0766
* fix formattingMike Bayer2020-08-041-1/+1
| | | | Change-Id: I8315cfef6e5c4b87d64fc770998a1229cc690870
* Add note that fast_executemany uses memoryMike Bayer2020-08-041-7/+11
| | | | | | | | Ideally this would be a per-execution option, or Pyodbc could perhaps run the data in chunks. Fixes: #5334 Change-Id: If4a11b312346b8e4c2b8cd38840b3a2ba56dec3b
* Document pyodbc built-in poolingMike Bayer2020-07-051-0/+26
| | | | | | | | | PyODBC apparently pools connections by default and this is a module-wide setting only. Documenent that this happens and how to disable it. Fixes: #5440 Change-Id: I415bda7beb2211c66991b6c804b0ddb4d79e427f
* Fix is_disconnect false positive for mssql+pyodbcGord Thompson2020-06-011-3/+3
| | | | | | | | | | Fixed an issue where the ``is_disconnect`` function in the SQL Server pyodbc dialect was incorrectly reporting the disconnect state when the exception messsage had a substring that matched a SQL Server ODBC error code. Fixes: #5359 Change-Id: I450c6818405a20f4daee20d58fce2d5ecb33e17f
* Move supports_sane_rowcount_returning = False to dialect levelGord Thompson2020-05-111-0/+3
| | | | | Fixes: #5321 Change-Id: Id83e98e9013818424c133297a850746302633158
* Set up absolute references for create_engine and relatedMike Bayer2020-04-141-1/+2
| | | | | | | includes more replacements for create_engine(), Connection, disambiguation of Result from future/baked Change-Id: Icb60a79ee7a6c45ea9056c211ffd1be110da3b5e
* Deprecate plain string in execute and introduce `exec_driver_sql`Federico Caselli2020-03-211-2/+2
| | | | | | | | | | | | | | | Execution of literal sql string is deprecated in the :meth:`.Connection.execute` and a warning is raised when used stating that it will be coerced to :func:`.text` in a future release. To execute a raw sql string the new connection method :meth:`.Connection.exec_driver_sql` was added, that will retain the previous behavior, passing the string to the DBAPI driver unchanged. Usage of scalar or tuple positional parameters in :meth:`.Connection.execute` is also deprecated. Fixes: #4848 Fixes: #5178 Change-Id: I2830181054327996d594f7f0d59c157d477c3aa9
* Fix handling of None as parameter for a datetimeoffset columnGord Thompson2020-02-101-4/+15
| | | | | | | | | | | | Fixed issue where the :class:`.mssql.DATETIMEOFFSET` type would not accommodate for the ``None`` value, introduced as part of the series of fixes for this type first introduced in :ticket:`4983`, :ticket:`5045`. Additionally, added support for passing a backend-specific date formatted string through this type, as is typically allowed for date/time types on most other DBAPIs. Fixes: #5132 Change-Id: Iab05d67382e0f550474d50e0c3c1c888521b678a
* happy new yearMike Bayer2020-01-011-1/+1
| | | | Change-Id: I08440dc25e40ea1ccea1778f6ee9e28a00808235
* Fix DATETIMEOFFSET formatting to preserve fractional seconds.Gord Thompson2019-12-311-2/+2
| | | | | | | | | | | | | Fixed issue where a timezone-aware ``datetime`` value being converted to string for use as a parameter value of a :class:`.mssql.DATETIMEOFFSET` column was omitting the fractional seconds. Fixes: #5045 Closes: #5046 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5046 Pull-request-sha: 99dc7b23f69b7b068795a02d20b88bf352c7dcd7 Change-Id: I971629466fe0675536bbdf55693f0c1821dfb3cc
* Add note re: pyodbc keywords in lowercase.Gord Thompson2019-12-031-0/+2
|
* Add DATETIMEOFFSET support for mssql+pyodbcGord Thompson2019-11-291-0/+48
| | | | | | | | | | | | | | | Repaired support for the :class:`.mssql.DATETIMEOFFSET` datatype on PyODBC, by adding PyODBC-level result handlers as it does not include native support for this datatype. This includes usage of the Python 3 "timezone" tzinfo subclass in order to set up a timezone, which on Python 2 makes use of a minimal backport of "timezone" in sqlalchemy.util. Fixes: #4983 Closes: #4986 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4986 Pull-request-sha: e3a5a8dda01c7580dc93271092c4f9beaac4be11 Change-Id: Ia4c7c0d1971c6c0492515bd5fa0b1799f07fee1c
* Improve SQL Server pyodbc documentationMike Bayer2019-10-311-13/+18
| | | | | | | | | | | | | | | | | | | | While we were told years ago that ODBC is intended to be used with DSNs only, however this use does not correspond well with how most other database connectivity systems work in that modern systems already have their own registries of connection information in any case, meaning this is usually the best place to add details such as hostnames and driver names, rather than having them locked away in a server-specific ODBC registry. So here we dial back the language that one style or another of connecting is "preferred"; both styles are supported equally, and the critical advantage of hostname mapping in that the target database name is both explicit as well as modifyable is also added. Add additional background for how DSNs work and refine other sentences. "URL encoding" is the correct terminology for adding spaces and special characters to a URL. Change-Id: I13a74432976e6d3166633b98f9bb84c4856caac8
* Enable F841Mike Bayer2019-06-201-1/+1
| | | | | | | | | | | This is a very useful assertion which prevents unused variables from being set up allows code to be more readable and sometimes even more efficient. test suites seem to be where the most problems are and there do not seem to be documentation examples that are using this, or at least the linter is not taking effect within rst blocks. Change-Id: I2b3341d8dd14da34879d8425838e66a4b9f8e27d
* Changed urllib.quote_plus to urllib.parse.quote_plus (Python 3 versio…ericdeansanchez2019-03-181-2/+2
| | | | | | | | | | Fixes: #4542 Closes: #4546 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4546 Pull-request-sha: 95d905cdcc33f44ff21d13e411e4a17843e6b54a Change-Id: Ibaf0852822e281e79770763e7e3550270d26cf66
* happy new yearMike Bayer2019-01-111-1/+1
| | | | Change-Id: I6a71f4924d046cf306961c58dffccf21e9c03911
* Post black reformattingMike Bayer2019-01-061-8/+13
| | | | | | | | | | | | | Applied on top of a pure run of black -l 79 in I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9, this set of changes resolves all remaining flake8 conditions for those codes we have enabled in setup.cfg. Included are resolutions for all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I4f72d3ba1380dd601610ff80b8fb06a2aff8b0fe
* Run black -l 79 against all source filesMike Bayer2019-01-061-41/+61
| | | | | | | | | | | | | | This is a straight reformat run using black as is, with no edits applied at all. The black run will format code consistently, however in some cases that are prevalent in SQLAlchemy code it produces too-long lines. The too-long lines will be resolved in the following commit that will resolve all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9
* Add pyodbc fast_executemanyMike Bayer2018-07-101-1/+36
| | | | | | | | | Added ``fast_executemany=True`` parameter to the SQL Server pyodbc dialect, which enables use of pyodbc's new performance feature of the same name when using Microsoft ODBC drivers. Change-Id: I743fa7280e8f709addd330cfc7682623701cbb2e Fixes: #4158
* Filter non-integer characters from pyodbc SQL Server versionMike Bayer2018-03-301-2/+4
| | | | | | | | | | Adjusted the SQL Server version detection for pyodbc to only allow for numeric tokens, filtering out non-integers, since the dialect does tuple- numeric comparisons with this value. This is normally true for all known SQL Server / pyodbc drivers in any case. Change-Id: I4ab18a07e19231091b5e877ba1fccd5eda72a992 Fixes: #4227
* Merge "Adjust tests for pyodbc 4.0.22"mike bayer2018-01-241-1/+0
|\
| * Adjust tests for pyodbc 4.0.22Mike Bayer2018-01-241-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | pyodbc 4.0.22 is no longer allowing a datetime to be truncated into a date, and additionally is asserting that numeric truncation is not occurring; previously, it looks like we could send a decimal of -1E-25 through the driver but we were only getting back -1E-20, the test failed to check this. Not clear if the larger precision worked fully at some point, but in any case, it doesn't work now so just remove those values from the test. Change-Id: I66c7863b1708eb72f48173083b4ef78c93893b52
* | Add 10054 to ODBC / SQL Server disconnect codesMike Bayer2018-01-161-1/+2
|/ | | | | Change-Id: I6e2518232608f47515b96984b4b7a41b8385975a Fixes: #4164
* happy new yearMike Bayer2018-01-121-1/+1
| | | | Change-Id: I3ef36bfd0cb0ba62b3123c8cf92370a43156cf8f
* Fix / consolidate for SQL Server BINARY, VARBINARYBen Shen2017-10-251-2/+22
| | | | | | | | | | | | Fixed bug where sqltypes.BINARY and sqltypes.VARBINARY datatypes would not include correct bound-value handlers for pyodbc, which allows the pyodbc.NullParam value to be passed that helps with FreeTDS. Co-authored by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: I6e3c16a69465b4fbc7b17a1927fb5e66acee93cb Pull-request: https://github.com/zzzeek/sqlalchemy/pull/386 Fixes: #4121
* Add full list of pyodbc error codes for MSSQLMike Bayer2017-09-281-0/+10
| | | | | | | | | Moved the SQL server error codes out of connnectors/pyodbc.py and into mssql/pyodbc.py. Added complete list of odbc-related disconnect codes. Change-Id: Icd84a920dbfa1f188847f859654ff6f7a48170f1 Fixes: #4095
* Add SQL Server CI coverageMike Bayer2017-08-311-31/+17
| | | | Change-Id: Ida0d01ae9bcc0573b86e24fddea620a38c962822
* Support python3.6Mike Bayer2017-01-131-2/+2
| | | | | | | | | | | Corrects some warnings and adds tox config. Adds DeprecationWarning to the error category. Large sweep for string literals w/ backslashes as this is common in docstrings Co-authored-by: Andrii Soldatenko Fixes: #3886 Change-Id: Ia7c838dfbbe70b262622ed0803d581edc736e085 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/337
* update for 2017 copyrightMike Bayer2017-01-041-1/+1
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* Catch DBAPIError instead of ProgrammingError for pyodbc failMike Bayer2016-10-071-2/+3
| | | | | Change-Id: Ide9e916d02fbbef549aa2838d1402c2b091e701d Fixes: #3820
* Use SQL Server SERVERPROPERTY for version info w/ pyodbcMike Bayer2016-10-041-1/+20
| | | | | | | | | Updated the server version info scheme for pyodbc to use SQL Server SERVERPROPERTY(), rather than relying upon pyodbc.SQL_DBMS_VER, which continues to be unreliable particularly with FreeTDS. Change-Id: I4ff49ae13c8ff51bd764980131d41c18d73d87ce Fixes: #3814
* - add notes for pyodbc limitations with rowcount fixes #3675Mike Bayer2016-03-151-0/+7
|
* - happy new yearMike Bayer2016-01-291-1/+1
|
* - Fixed issue when using :class:`.VARBINARY` type in conjunction withMike Bayer2015-06-221-2/+20
| | | | | | | | | an INSERT of NULL + pyodbc; pyodbc requires a special object be passed in order to persist NULL. As the :class:`.VARBINARY` type is now usually the default for :class:`.LargeBinary` due to :ticket:`3039`, this issue is partially a regression in 1.0. The pymssql driver appears to be unaffected. fixes #3464