DB-API interface to Microsoft SQL Server for Python. (new Cython-based version)
Project description
pymssql - DB-API interface to Microsoft SQL Server
A simple database interface to Microsoft SQL Server (MS-SQL) for Python that builds on top of FreeTDS to provide a Python DB-API (PEP-249) interface to SQL Server.
Detailed information on pymssql is available on the website:
New development is happening on GitHub at:
https://github.com/pymssql/pymssql
There is a Google Group for discussion at:
https://groups.google.com/forum/?fromgroups#!forum/pymssql
Do you use pymssql?
Can you take a minute and fill out this survey to help us prioritize development tasks?
https://www.surveymonkey.com/s/KMQ8BM5
Recent Changes
Version 2.1.0 - 2014-02-25 - Marc Abramowitz
Features
Sphinx-based documentation (GH-149)
Read it online at http://pymssql.org/
Thanks, Ramiro Morales!
See:
“Green” support (GH-135)
Lets you use pymssql with cooperative multi-tasking systems like gevent and have pymssql call a callback when it is waiting for a response from the server. You can set this callback to yield to another greenlet, coroutine, etc. For example, for gevent, you could do:
def wait_callback(read_fileno): gevent.socket.wait_read(read_fileno) pymssql.set_wait_callback(wait_callback)
The above is useful if you’re say, running a gunicorn server with the gevent worker. With this callback in place, when you send a query to SQL server and are waiting for a response, you can yield to other greenlets and process other requests. This is super useful when you have high concurrency and/or slow database queries and lets you use less gunicorn worker processes and still handle high concurrency.
Better error messages.
E.g.: For a connection failure, instead of:
pymssql.OperationalError: (20009, 'Net-Lib error during Connection refused')
the dberrstr is also included, resulting in:
pymssql.OperationalError: (20009, 'DB-Lib error message 20009, severity 9:\nUnable to connect: Adaptive Server is unavailable or does not exist\nNet-Lib error during Connection refused\n')
See:
In the area of error messages, we also made this change:
execute: Raise ColumnsWithoutNamesError when as_dict=True and missing column names (GH-160)
because the previous behavior was very confusing; instead of raising an exception, we would just return row dicts with those columns missing. This prompted at least one question on the mailing list (https://groups.google.com/forum/?fromgroups#!topic/pymssql/JoZpmNZFtxM), so we thought it was better to handle this explicitly by raising an exception, so the user would understand what went wrong.
See:
Performance improvements
You are most likely to notice a difference from these when you are fetching a large number of rows.
Reworked row fetching (GH-159)
There was a rather large amount of type conversion occuring when fetching a row from pymssql. The number of conversions required have been cut down significantly with these changes. Thanks Damien, Churchill!
See:
Modify get_row() to use the CPython tuple API (GH-178)
This drops the previous method of building up a row tuple and switches to using the CPython API, which allows you to create a correctly sized tuple at the beginning and simply fill it in. This appears to offer around a 10% boost when fetching rows from a table where the data is already in memory. Thanks Damien, Churchill!
See:
MSSQLConnection: Add with (context manager) support (GH-171)
This adds with statement support for MSSQLConnection in the _mssql module – e.g.:
with mssqlconn() as conn: conn.execute_query("SELECT @@version AS version")
We already have with statement support for the pymssql module.
See:
Allow passing in binary data (GH-179)
Use the bytearray type added in Python 2.6 to signify that this is binary data and to quote it accordingly. Also modify the handling of str/bytes types checking the first 2 characters for b’0x’ and insert that as binary data.
See:
Add support for binding uuid.UUID instances to stored procedures input params (GH-143)
Thanks, Ramiro Morales!
See:
The version number is now stored in one place, in pymssql_version.h This makes it easier to update the version number and not forget any places, like I did with pymssql 2.0.1
See:
Improved support for using py.test as test runner (GH-183)
See:
Improved PEP-8 and pylint compliance
Bug Fixes
GH-142 (“Change how *.pyx files are included in package”) - this should prevent pymssql.pyx and _mssql.pyx from getting copied into the root of your virtualenv. Thanks, @Arfrever!
See:
GH-145 (“Prevent error string growing with repeated failed connection attempts.”)
See:
GH-151 (“err_handler: Don’t clobber dberrstr with oserrstr”)
See:
GH-152 (“_mssql.pyx: Zero init global last_msg_* vars”)
See:
GH-177 (“binary columns sometimes are processed as varchar”) Better mechanism for pymssql to detect that user is passing binary data.
See:
buffer overflow fix (GH-182)
See:
Return uniqueidentifer columns as uuid.UUID objects on Python 3
Version 2.0.1 - 2013-10-27 - Marc Abramowitz
MANIFEST.in: Add “*.rst” to prevent install error: “IOError: [Errno 2] No such file or directory: ‘ChangeLog_highlights.rst’”
Version 2.0.0 - 2013-10-25 - Marc Abramowitz
First official release of pymssql 2.X (Cython-based code) to PyPI!
Compared to pymssql 1.X, this version offers:
See ChangeLog for older history…
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for pymssql-2.1.0-py3.4-macosx-10.6-intel.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | beba3b8d9e843f9f67fe223a5f5f0a096091acc23770fbf49ffeff04a25ec273 |
|
MD5 | 85b0843729570563125e66b9d3ee71e8 |
|
BLAKE2b-256 | a727a9234709cd3c60240df87d8c24888f580ab85586f52b15f6ad8df1937f1f |
Hashes for pymssql-2.1.0-py3.3-macosx-10.6-intel.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f1c430d96cb5960b453613334e58ed5bede9c7f77c403e36637e04bc1918e78 |
|
MD5 | 93121fd3d58d9ebe0e9e74070d5757d4 |
|
BLAKE2b-256 | 6b79528a5657fa7a686baeb9156b07fc43df9b873952d993edb421f781833209 |
Hashes for pymssql-2.1.0-py2.7-macosx-10.4-x86_64.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50dd35482a7d1df205a223d60bfdb7fd35b878616fb6ea18033562ecb26f68ea |
|
MD5 | b9f53accd4c99d19152e4bb6f428b74c |
|
BLAKE2b-256 | 4a1c3bc9e602f072a52f176e15ffb7289ae6c020d064a0f92b01743a614f1e14 |
Hashes for pymssql-2.1.0-py2.6-macosx-10.8-intel.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0b920ebd786c52b662e3f2e8a3c54c22d436fa24d97f7aa9d3e2eccd40e44f9 |
|
MD5 | 35b771ee210987611cedde341d4dc640 |
|
BLAKE2b-256 | 44ba34f48a23c1563b8c4a73da0b331f73b6f730e392356d829e84cbd0e2cb4d |
Hashes for pymssql-2.1.0-cp34-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c952605a21c596a2c103aab0c913f859074750c60fa71acef27b98404c9ff4ba |
|
MD5 | ef3832358ee74e46559eebff30e94fc9 |
|
BLAKE2b-256 | 75c0af78f7299acd31cd88faa7246396b3cec2290d9c43ab977de70b7f1b584b |
Hashes for pymssql-2.1.0-cp34-cp34m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b92072233cc1138433126615e11c568a4d7dda00c34e6b3b3a220f311b8ae12 |
|
MD5 | 142cbf2496e58409b7d2937858b049d7 |
|
BLAKE2b-256 | 7d4aeda3682068100296e11fa19ba1251140ef5f1f6f20f28d8f1305aa76c790 |
Hashes for pymssql-2.1.0-cp33-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d54146079f32558ae71a4266d905b3f73e11775d691ae3a410bfe5a9691834e |
|
MD5 | 61800cc9e0430f499ff02af4d4af2310 |
|
BLAKE2b-256 | c5461f369e6ec98324dff21d44e9719c7fa72793fc183e874f17f9ccdb596623 |
Hashes for pymssql-2.1.0-cp33-cp33m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c548d6816a81501fed8aca8adeeeede567b190578794a357702ba1401f876a89 |
|
MD5 | 085a2d312c6b2c1eac51a82bfb1a23af |
|
BLAKE2b-256 | 400adccebfd281b8913e4499ef7c779c71ec7aa690b5c52910b67f7949e30ccd |
Hashes for pymssql-2.1.0-cp27-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 626c78766f2f55a369f99642b1545cd0b2c4df9e7efa5c4c79a69bd1155fd6e7 |
|
MD5 | eca99ecef4e31430a3212a6ffcfca31b |
|
BLAKE2b-256 | 74a74d254e961cec9a3377aeb0d9d330c02e61da51e360b45549d3a127a65538 |
Hashes for pymssql-2.1.0-cp27-none-macosx_10_4_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f8edc391f77e1f96d04907a6f9c64b60967770d5ffe20bae14135810223e285 |
|
MD5 | ff8ba7918227b12acfe542517d9a8bfe |
|
BLAKE2b-256 | 26a930e8a8348e42bd96bcd9723f32d61c20eb5f7fc7cb50d5ed2c23822d08c1 |
Hashes for pymssql-2.1.0-cp26-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9ab8c82099e73b3ae4bfb05aa623c4c5e6e98d3a86d8b212013b997f2f6ddea |
|
MD5 | ae19920575aa51efd2ec98cd5a316e43 |
|
BLAKE2b-256 | aef21d3340f063f003ee9dcdc48ae8fdb47a35ce98118d7c33331e83a013975f |
Hashes for pymssql-2.1.0-cp26-none-macosx_10_8_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca687544d6961efb9f02cd730a0e081982c2d64330d5b03f8ac68a67fc0bafb2 |
|
MD5 | d8f9be4f7bb992dbf3d93f531e50ab74 |
|
BLAKE2b-256 | 7dcdfba4e2a210f64c26ef13bc19b6d0fa7ddb844aaab2ebacab3bbafbb7aac4 |