summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/mssql/pymssql.py
Commit message (Collapse)AuthorAgeFilesLines
* audition pymssql once more; retire sane_rowcount_returningMike Bayer2023-03-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | pymssql seems to be maintained again and seems to be working completely, so let's try re-enabling it. Fixed issue in the new :class:`.Uuid` datatype which prevented it from working with the pymssql driver. As pymssql seems to be maintained again, restored testing support for pymssql. Tweaked the pymssql dialect to take better advantage of RETURNING for INSERT statements in order to retrieve last inserted primary key values, in the same way as occurs for the mssql+pyodbc dialect right now. Identified that the ``sqlite`` and ``mssql+pyodbc`` dialects are now compatible with the SQLAlchemy ORM's "versioned rows" feature, since SQLAlchemy now computes rowcount for a RETURNING statement in this specific case by counting the rows returned, rather than relying upon ``cursor.rowcount``. In particular, the ORM versioned rows use case (documented at :ref:`mapper_version_counter`) should now be fully supported with the SQL Server pyodbc dialect. Change-Id: I38a0666587212327aecf8f98e86031ab25d1f14d References: #5321 Fixes: #9414
* happy new year 2023Mike Bayer2023-01-031-1/+1
| | | | Change-Id: I625af65b3fb1815b1af17dc2ef47dd697fdc3fb1
* Try running pyupgrade on the codeFederico Caselli2022-11-161-4/+2
| | | | | | | | command run is "pyupgrade --py37-plus --keep-runtime-typing --keep-percent-format <files...>" pyupgrade will change assert_ to assertTrue. That was reverted since assertTrue does not exists in sqlalchemy fixtures Change-Id: Ie1ed2675c7b11d893d78e028aad0d1576baebb55
* remove notes re: current pymssql DBAPI featuresMike Bayer2022-08-191-18/+0
| | | | | Fixes: #8337 Change-Id: Ib0c107bb386489dcb6d1683f29d0a9574dd96f1e
* inline mypy config; files ignoring type errors for the momentMike Bayer2022-04-281-0/+2
| | | | | | | | | | | | | | | | | | | to simplify pyproject.toml change the remaining files that aren't going to be typed on this first pass (unless of course someone wants to type some of these) to include # mypy: ignore-errors. for the moment, only a handful of ORM modules are to have more type checking implemented. It's important that ignore-errors is used and not "# type: ignore", as in the latter case, mypy doesn't even read the existing types in the file, which makes it impossible to type any files that refer to those modules at all. to simplify ongoing typing work use inline mypy config for remaining files that are "done" for now, indicating the level of type checking they currently have. Change-Id: I98669c1a305c2f0adba85d10b5425541f3fe9533
* pep-484 for engineMike Bayer2022-03-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All modules in sqlalchemy.engine are strictly typed with the exception of cursor, default, and reflection. cursor and default pass with non-strict typing, reflection is waiting on the multi-reflection refactor. Behavioral changes: * create_connect_args() methods return a tuple of list, dict, rather than a list of list, dict * removed allow_chars parameter from pyodbc connector ._get_server_version_info() method * the parameter list passed to do_executemany is now a list in all cases. previously, this was being run through dialect.execute_sequence_format, which defaults to tuple and was only intended for individual tuple params. * broke up dialect.dbapi into dialect.import_dbapi class method and dialect.dbapi module object. added a deprecation path for legacy dialects. it's not really feasible to type a single attr as a classmethod vs. module type. The "type_compiler" attribute also has this problem with greater ability to work around, left that one for now. * lots of constants changing to be Enum, so that we can type them. for fixed tuple-position constants in cursor.py / compiler.py (which are used to avoid the speed overhead of namedtuple), using Literal[value] which seems to work well * some tightening up in Row regarding __getitem__, which we can do since we are on full 2.0 style result use * altered the set_connection_execution_options and set_engine_execution_options event flows so that the dictionary of options may be mutated within the event hook, where it will then take effect as the actual options used. Previously, changing the dict would be silently ignored which seems counter-intuitive and not very useful. * A lot of DefaultDialect/DefaultExecutionContext methods and attributes, including underscored ones, move to interfaces. This is not fully ideal as it means the Dialect/ExecutionContext interfaces aren't publicly subclassable directly, but their current purpose is more of documentation for dialect authors who should (and certainly are) still be subclassing the DefaultXYZ versions in all cases Overall, Result was the most extremely difficult class hierarchy to type here as this hierarchy passes through largely amorphous "row" datatypes throughout, which can in fact by all kinds of different things, like raw DBAPI rows, or Row objects, or "scalar"/Any, but at the same time these types have meaning so I tried still maintaining some level of semantic markings for these, it highlights how complex Result is now, as it's trying to be extremely efficient and inlined while also being very open-ended and extensible. Change-Id: I98b75c0c09eab5355fc7a33ba41dd9874274f12a
* happy new year 2022Mike Bayer2022-01-061-1/+1
| | | | Change-Id: I49abf2607e0eb0623650efdf0091b1fb3db737ea
* Replace c extension with cython versions.workflow_test_cythonFederico Caselli2021-12-171-1/+1
| | | | | | | | | | | | | | | Re-implement c version immutabledict / processors / resultproxy / utils with cython. Performance is in general in par or better than the c version Added a collection module that has cython version of OrderedSet and IdentitySet Added a new test/perf file to compare the implementations. Run ``python test/perf/compiled_extensions.py all`` to execute the comparison test. See results here: https://docs.google.com/document/d/1nOcDGojHRtXEkuy4vNXcW_XOJd9gqKhSeALGG3kYr6A/edit?usp=sharing Fixes: #7256 Change-Id: I2930ef1894b5048210384728118e586e813f6a76 Signed-off-by: Federico Caselli <cfederico87@gmail.com>
* provide connectionfairy on initializeMike Bayer2021-11-291-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is so that dialect methods that are called within init can assume the same argument structure as when they are called in other places; we can nail down the type of object as well. This change seems to mostly impact the isolation level routines in the dialects, as these are called during initialize() as well as on established connections. these methods can now assume a non-proxied DBAPI connection object in all cases, as it is commonly required that attributes like ".autocommit" are set on the object which don't work well in a proxied situation. Other changes: * adds an interface for the "connectionfairy" concept called PoolProxiedConnection. * Removes ``Connectable`` superclass of Connection. ``Connectable`` was originally meant to provide for the "method which accepts connection or engine" theme. As this pattern is greatly reduced in 2.0 and Engine no longer extends from it, the ``Connectable`` superclass doesnt serve any real purpose. Leading from that, to set this in I also applied pep 484 annotations to the Dialect base, and then in the interests of seeing some of the typing information show up in my IDE did a little bit for Engine, Connection and others. I hope that it's feasible that we can add annotations to specific classes and attributes ahead of when we actually try to mass-populate the whole library. This was the original spirit of pep-484 that we can apply annotations gradually. I do of course want to try to do a mass-populate although i think even in that case we will end up doing a lot of manual work anyway (in particular for the changes here which are distinct from what the stubs have). Fixes: #7122 Change-Id: I5dd7fbff8a7ae520a81c165091af12a6a68826db
* fully support isolation_level parameter in base dialectMike Bayer2021-11-181-0/+3
| | | | | | | | | | | | | | | | | | | | Generalized the :paramref:`_sa.create_engine.isolation_level` parameter to the base dialect so that it is no longer dependent on individual dialects to be present. This parameter sets up the "isolation level" setting to occur for all new database connections as soon as they are created by the connection pool, where the value then stays set without being reset on every checkin. The :paramref:`_sa.create_engine.isolation_level` parameter is essentially equivalent in functionality to using the :paramref:`_engine.Engine.execution_options.isolation_level` parameter via :meth:`_engine.Engine.execution_options` for an engine-wide setting. The difference is in that the former setting assigns the isolation level just once when a connection is created, the latter sets and resets the given level on each connection checkout. Fixes: #6342 Change-Id: Id81d6b1c1a94371d901ada728a610696e09e9741
* Replace all http:// links to https://Federico Caselli2021-07-041-2/+2
| | | | | | Also replace http://pypi.python.org/pypi with https://pypi.org/project Change-Id: I84b5005c39969a82140706472989f2a30b0c7685
* Improve regexp used by pymssql to parse db versionFederico Caselli2021-06-211-1/+1
| | | | | | | | | Made improvements to the server version regexp used by the pymssql dialect to prevent a regexp overflow in case of an invalid version string. Fixes: #5557 Change-Id: Ia3e95a9f11f5a121d84474c97f6b122cf8d9c9cf
* 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
* happy new yearMike Bayer2021-01-041-1/+1
| | | | Change-Id: Ic5bb19ca8be3cb47c95a0d3315d84cb484bac47c
* Add note re: pymssql not in CIGord Thompson2020-05-161-0/+5
| | | | Change-Id: I45f78131ffe1881a3965e8aa41bbc46da7d43a5b
* Fix typo in pymssql documentation; minor clarificationGord Thompson2020-04-201-2/+3
| | | | Change-Id: I4aaf0627d2f1ccae82c2eb41db9ec219d73ce4ea
* Update pymssql information for mssql dialectGord Thompson2020-04-201-5/+18
| | | | Change-Id: I94cf63299a094b53e7078b282311f7d0faa256a6
* Deprecate plain string in execute and introduce `exec_driver_sql`Federico Caselli2020-03-211-1/+1
| | | | | | | | | | | | | | | 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
* happy new yearMike Bayer2020-01-011-1/+1
| | | | Change-Id: I08440dc25e40ea1ccea1778f6ee9e28a00808235
* Recognize message 20047 as disconnect event in MSDialect_pymssqlJon Schuff2019-05-151-0/+1
| | | | | | | | | | | | Added error code 20047 to "is_disconnect" for pymssql. Pull request courtesy Jon Schuff. Fixes: #4680 Closes: #4681 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4681 Pull-request-sha: bc81c935ec0e352734d9ad1b322caf6d08079c3d Change-Id: Ifc7ffc4c933b08a34fad537dc48e05d2cfa66d42
* happy new yearMike Bayer2019-01-111-1/+1
| | | | Change-Id: I6a71f4924d046cf306961c58dffccf21e9c03911
* Post black reformattingMike Bayer2019-01-061-5/+8
| | | | | | | | | | | | | 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-20/+18
| | | | | | | | | | | | | | 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
* happy new yearMike Bayer2018-01-121-1/+1
| | | | Change-Id: I3ef36bfd0cb0ba62b3123c8cf92370a43156cf8f
* Add SQL Server CI coverageMike Bayer2017-08-311-6/+6
| | | | Change-Id: Ida0d01ae9bcc0573b86e24fddea620a38c962822
* Add preparer to pymssql that disables percent doublingMike Bayer2017-08-301-1/+12
| | | | | | | | | | | | | Fixed the pymssql dialect so that percent signs in SQL text, such as used in modulus expressions or literal textual values, are **not** doubled up, as seems to be what pymssql expects. This is despite the fact that the pymssql DBAPI uses the "pyformat" parameter style which itself considers the percent sign to be significant. Tests are part of standard suite already (CI has been disabled) Change-Id: Ie05de403caefcba3292a967183a995e95a5854d5 Fixes: #4057
* Implement AUTOCOMMIT for pyodbc, pymssqlMike Bayer2017-08-291-0/+8
| | | | | | | In prep for CI coverage for SQL Server, allow AUTOCOMMIT isolation level to work Change-Id: I850b977e75f53385986f2c181be4e4412dd3b3f4
* update for 2017 copyrightMike Bayer2017-01-041-1/+1
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* Add "message 20017" (unexpected EOF from the server) to mssql.Ken Robbins2016-09-191-0/+1
| | | | | | Fixes: #3791 Change-Id: I0dade4fe0ecbb53b4a66881594f362986ba73ae8 Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/89
* Fix pymssql sample URLMike Bayer2016-04-271-1/+1
| | | | | | | | A slash is required before building out the query string portion. Change-Id: Ie97fd3d07047d78e17cbaffed4ff54960a2b956e Fixes: #3696 (cherry picked from commit 83a9e6e1fac276090e60136aa4e9234ae23bc25a)
* - happy new yearMike Bayer2016-01-291-1/+1
|
* - Added the error "20006: Write to the server failed" to the listMike Bayer2015-11-301-1/+2
| | | | | | of disconnect errors for the pymssql driver, as this has been observed to render a connection unusable. fixes #3585
* - pymssql has PEP249 Binary contructor since 2.1.1pr/166Ramiro Morales2015-04-051-4/+5
| | | | See https://github.com/pymssql/pymssql/commit/e7fb15dd29090e1f1bb570842b53aea1ec32d8f0
* - copyright 2015Mike Bayer2015-03-101-1/+1
|
* - Fixed the version string detection in the pymssql dialect toMike Bayer2014-09-161-1/+1
| | | | | | work with Microsoft SQL Azure, which changes the word "SQL Server" to "SQL Azure". fixes #3151
* - apply pep8 formatting to sqlalchemy/sql, sqlalchemy/util, sqlalchemy/dialects,Brian Jarrett2014-07-201-2/+3
| | | | sqlalchemy/orm, sqlalchemy/event, sqlalchemy/testing
* - break up the <authors> copyright comment as part of a passMike Bayer2014-07-091-1/+2
| | | | to get all flake8 passing
* take out the support paragraph and just put a basic introMike Bayer2014-03-091-9/+3
|
* dialects/mssql/pymssql.py: Remove second two paragraphs, as requested by ↵pr/75Marc Abramowitz2014-03-031-9/+0
| | | | @zzzeek.
* Update pymssql dialect description, remove "limitations" sectionMarc Abramowitz2014-02-271-9/+16
|
* Update URL for pymssqlMarc Abramowitz2014-02-271-1/+1
|
* - happy new yearMike Bayer2014-01-051-1/+1
|
* Remove terminated connections from the pool.pr/51John Anderson2013-12-161-0/+1
| | | | | | In pymssql, if you terminate a long running query manually it will give you a connection reset by peer message, but this connection remains in the pool and will be re-used.
* Merged in sontek/sqlalchemy/add_better_disconnect_checks (pull request #47)Mike Bayer2013-03-291-0/+2
|\ | | | | | | Add disconnect check on timeouts
| * cleaned up errors, only check for connection timeout for nowJohn Anderson2013-03-181-3/+2
| |
| * Added disconnect checks for timeout, unable to read, and unable to writeJohn Anderson2013-03-181-0/+3
| |
* | dialects/mssql/pymssql.py: Modify module.Binary to work properly withMarc Abramowitz2013-03-181-1/+1
|/ | | | | | byte strings in Python 3 Fixes http://www.sqlalchemy.org/trac/ticket/2683
* happy new year (see #2645)Diana Clarke2013-01-011-1/+1
|
* kill me now, pep8 pass, so closeDiana Clarke2012-11-201-0/+1
|
* just a pep8 passDiana Clarke2012-11-201-2/+2
|