Giter VIP home page Giter VIP logo

pymssql's Introduction

pymssql - DB-API interface to Microsoft SQL Server

A simple database interface for Python that builds on top of FreeTDS to provide a Python DB-API (PEP-249) interface to Microsoft SQL Server.

Detailed information on pymssql is available on the website:

pymssql.readthedocs.io

New development is happening on GitHub at:

github.com/pymssql/pymssql

There is a Google Group for discussion at:

groups.google.com

Getting started

pymssql wheels are available from PyPi. To install it run:

pip install -U pip
pip install pymssql

Most of the times this should be all what's needed. The official pymssql wheels bundle a static copy of FreeTDS and have SSL support so they can be used to connect to Azure.

Note

On some Linux distributions pip version is too old to support all the flavors of manylinux wheels, so upgrading pip is necessary. An example of such distributions would be Ubuntu 18.04 or Python3.6 module in RHEL8 and CentOS8.

Basic example

conn = pymssql.connect(server, user, password, "tempdb")
cursor = conn.cursor(as_dict=True)

cursor.execute('SELECT * FROM persons WHERE salesrep=%s', 'John Doe')
for row in cursor:
    print("ID=%d, Name=%s" % (row['id'], row['name']))

conn.close()

pymssql's People

Contributors

bladams avatar damoxc avatar dependabot[bot] avatar epa avatar erosennin avatar guillaumep avatar johnnymo87 avatar jpgimenez avatar juntangc avatar korverdev avatar matusvalo avatar mavlyutov avatar mikhailsidorov avatar mpagel avatar msabramo avatar ph89 avatar primozgodec avatar quentinlegay avatar ramiro avatar randommuser avatar rsyring avatar sietse avatar simonbiggs avatar simonstjg avatar ski7777 avatar skinowski avatar summonholmes avatar termim avatar testsr avatar wb7777 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pymssql's Issues

import pymssql crashes python

From nmeixler on April 21, 2010 14:52:55

What steps will reproduce the problem? 1. download newest pymssql for windows on this website
2. run the installer
3. try to import pymssql module, python crashes What is the expected output? What do you see instead? i expect it to not crash, python crashes What version of the product are you using? On what operating system? python2.6 on windows XP 2002SP3 32bit Please provide any additional information below.

Original issue: http://code.google.com/p/pymssql/issues/detail?id=2

Threaded Tests caused crash

From [email protected] on April 16, 2011 12:25:55

testErrorSprocThreadedUse (tests.test_threaded.ThreadedTests) ... SKIP
testErrorThreadedUse (tests.test_threaded.ThreadedTests) ... ok
testThreadedUse (tests.test_threaded.ThreadedTests) ... *** glibc detected *** /home/rsyring/.virtualenvs/pymssql/bin/python: double free or corruption (!prev): 0x0000000002a129a0 ***
======= Backtrace: =========
/lib/libc.so.6(+0x775b6)[0x7faf3d57c5b6]
/lib/libc.so.6(cfree+0x73)[0x7faf3d582e83]
/home/rsyring/.virtualenvs/pymssql/bin/python[0x44fc6f]
/home/rsyring/.virtualenvs/pymssql/bin/python(PyObject_GenericGetAttr+0x140)[0x453d10]
/home/rsyring/.virtualenvs/pymssql/bin/python(PyEval_EvalFrameEx+0x2b75)[0x4a5665]
/home/rsyring/.virtualenvs/pymssql/bin/python(PyEval_EvalFrameEx+0x5a60)[0x4a8550]
======= Memory map: ========
00400000-0061c000 r-xp 00000000 fc:00 3039687 /home/rsyring/.virtualenvs/pymssql/bin/python
0081b000-0081c000 r--p 0021b000 fc:00 3039687 /home/rsyring/.virtualenvs/pymssql/bin/python
0081c000-0087e000 rw-p 0021c000 fc:00 3039687 /home/rsyring/.virtualenvs/pymssql/bin/python
0087e000-0088d000 rw-p 00000000 00:00 0
02338000-03441000 rw-p 00000000 00:00 0 [heap]
7faf34000000-7faf34021000 rw-p 00000000 00:00 0
7faf34021000-7faf38000000 ---p 00000000 00:00 0
7faf393de000-7faf393f4000 r-xp 00000000 fc:00 603 /lib/libgcc_s.so.1
7faf393f4000-7faf395f3000 ---p 00016000 fc:00 603 /lib/libgcc_s.so.1
7faf395f3000-7faf395f4000 r--p 00015000 fc:00 603 /lib/libgcc_s.so.1
7faf395f4000-7faf395f5000 rw-p 00016000 fc:00 603 /lib/libgcc_s.so.1
7faf395f5000-7faf395f6000 ---p 00000000 00:00 0
7faf395f6000-7faf39df6000 rw-p 00000000 00:00 0
7faf39df6000-7faf39df7000 ---p 00000000 00:00 0
7faf39df7000-7faf3a5f7000 rw-p 00000000 00:00 0
7faf3a5f7000-7faf3a5f9000 r-xp 00000000 fc:00 14450 /lib/libnss_mdns4.so.2
7faf3a5f9000-7faf3a7f8000 ---p 00002000 fc:00 14450 /lib/libnss_mdns4.so.2
7faf3a7f8000-7faf3a7f9000 r--p 00001000 fc:00 14450 /lib/libnss_mdns4.so.2
7faf3a7f9000-7faf3a7fa000 rw-p 00002000 fc:00 14450 /lib/libnss_mdns4.so.2
7faf3a7fa000-7faf3a810000 r-xp 00000000 fc:00 20688 /lib/libresolv-2.11.1.so
7faf3a810000-7faf3aa0f000 ---p 00016000 fc:00 20688 /lib/libresolv-2.11.1.so
7faf3aa0f000-7faf3aa10000 r--p 00015000 fc:00 20688 /lib/libresolv-2.11.1.so
7faf3aa10000-7faf3aa11000 rw-p 00016000 fc:00 20688 /lib/libresolv-2.11.1.so
7faf3aa11000-7faf3aa13000 rw-p 00000000 00:00 0
7faf3aa13000-7faf3aa18000 r-xp 00000000 fc:00 20681 /lib/libnss_dns-2.11.1.so
7faf3aa18000-7faf3ac17000 ---p 00005000 fc:00 20681 /lib/libnss_dns-2.11.1.so
7faf3ac17000-7faf3ac18000 r--p 00004000 fc:00 20681 /lib/libnss_dns-2.11.1.so
7faf3ac18000-7faf3ac19000 rw-p 00005000 fc:00 20681 /lib/libnss_dns-2.11.1.so
7faf3ac19000-7faf3ac1b000 r-xp 00000000 fc:00 14451 /lib/libnss_mdns4_minimal.so.2
7faf3ac1b000-7faf3ae1a000 ---p 00002000 fc:00 14451 /lib/libnss_mdns4_minimal.so.2
7faf3ae1a000-7faf3ae1b000 r--p 00001000 fc:00 14451 /lib/libnss_mdns4_minimal.so.2
7faf3ae1b000-7faf3ae1c000 rw-p 00002000 fc:00 14451 /lib/libnss_mdns4_minimal.so.2
7faf3ae1c000-7faf3ae1e000 r-xp 00000000 fc:00 1050680 /usr/lib/gconv/CP1252.so
7faf3ae1e000-7faf3b01d000 ---p 00002000 fc:00 1050680 /usr/lib/gconv/CP1252.so
7faf3b01d000-7faf3b01e000 r--p 00001000 fc:00 1050680 /usr/lib/gconv/CP1252.so
7faf3b01e000-7faf3b01f000 rw-p 00002000 fc:00 1050680 /usr/lib/gconv/CP1252.so
7faf3b01f000-7faf3b021000 r-xp 00000000 fc:00 1056540 /usr/lib/gconv/ISO8859-1.so
7faf3b021000-7faf3b220000 ---p 00002000 fc:00 1056540 /usr/lib/gconv/ISO8859-1.so
7faf3b220000-7faf3b221000 r--p 00001000 fc:00 1056540 /usr/lib/gconv/ISO8859-1.so
7faf3b221000-7faf3b222000 rw-p 00002000 fc:00 1056540 /usr/lib/gconv/ISO8859-1.so
7faf3b222000-7faf3b22e000 r-xp 00000000 fc:00 20682 /lib/libnss_files-2.11.1.so
7faf3b22e000-7faf3b42d000 ---p 0000c000 fc:00 20682 /lib/libnss_files-2.11.1.so
7faf3b42d000-7faf3b42e000 r--p 0000b000 fc:00 20682 /lib/libnss_files-2.11.1.so
7faf3b42e000-7faf3b42f000 rw-p 0000c000 fc:00 20682 /lib/libnss_files-2.11.1.so
7faf3b42f000-7faf3b439000 r-xp 00000000 fc:00 20684 /lib/libnss_nis-2.11.1.so
7faf3b439000-7faf3b638000 ---p 0000a000 fc:00 20684 /lib/libnss_nis-2.11.1.so
7faf3b638000-7faf3b639000 r--p 00009000 fc:00 20684 /lib/libnss_nis-2.11.1.so
7faf3b639000-7faf3b63a000 rw-p 0000a000 fc:00 20684 /lib/libnss_nis-2.11.1.so
7faf3b63a000-7faf3b651000 r-xp 00000000 fc:00 20677 /lib/libnsl-2.11.1.so
7faf3b651000-7faf3b850000 ---p 00017000 fc:00 20677 /lib/libnsl-2.11.1.so
7faf3b850000-7faf3b851000 r--p 00016000 fc:00 20677 /lib/libnsl-2.11.1.so
7faf3b851000-7faf3b852000 rw-p 00017000 fc:00 20677 /lib/libnsl-2.11.1.so
7faf3b852000-7faf3b854000 rw-p 00000000 00:00 0
7faf3b854000-7faf3b85c000 r-xp 00000000 fc:00 20678 /lib/libnss_compat-2.11.1.so
7faf3b85c000-7faf3ba5b000 ---p 00008000 fc:00 20678 /lib/libnss_compat-2.11.1.so
7faf3ba5b000-7faf3ba5c000 r--p 00007000 fc:00 20678 /lib/libnss_compat-2.11.1.so
7faf3ba5c000-7faf3ba5d000 rw-p 00008000 fc:00 20678 /lib/libnss_compat-2.11.1.so
7faf3ba5d000-7faf3ba79000 r-xp 00000000 fc:00 2892531 /home/rsyring/dev/python/pymssql/pymssql-src/pymssql.so
7faf3ba79000-7faf3bc78000 ---p 0001c000 fc:00 2892531 /home/rsyring/dev/python/pymssql/pymssql-src/pymssql.so
7faf3bc78000-7faf3bc79000 r--p 0001b000 fc:00 2892531 /home/rsyring/dev/python/pymssql/pymssql-src/pymssql.so
7faf3bc79000-7faf3bc7d000 rw-p 0001c000 fc:00 2892531 /home/rsyring/dev/python/pymssql/pymssql-src/pymssql.so
7faf3bc7d000-7faf3bc7e000 rw-p 00000000 00:00 0
7faf3bc7e000-7faf3bc84000 r-xp 00000000 fc:00 789208 /usr/lib/python2.6/dist-packages/zope/interface/_zope_interface_coptimizations.soAborted

But i was not able to reproduce a second time.

Original issue: http://code.google.com/p/pymssql/issues/detail?id=47

date column returns day value that is out of range

From [email protected] on April 06, 2011 22:04:39

I have the trunk building against FreeTDS shipped with Ubuntu 10.04 (0.82-1build6). I have also done a special build to use the configure line:

--enable-msdblib

with the same results. I did some debugging and the number being returned for di.day is 96.

Debug output follows:

2011-04-07 01:01:13,831 INFO sqlalchemy.engine.base.Engine.0x...bf10 BEGIN (implicit)
2011-04-07 01:01:13,831 INFO sqlalchemy.engine.base.Engine.0x...bf10 SELECT auth_applications.id AS auth_applications_id, auth_applications.createdts AS auth_applications_createdts, auth_applications.updatedts AS auth_applications_updatedts, auth_applications.name AS auth_applications_name
FROM auth_applications
WHERE auth_applications.id = %(param_1)s
2011-04-07 01:01:13,831 INFO sqlalchemy.engine.base.Engine.0x...bf10 {'param_1': 1}
+++ _mssql.MSSQLConnection.execute_query()
+++ _mssql.MSSQLConnection.format_and_run_query()
+++ _mssql.MSSQLConnection.cancel()
+++ _mssql.assert_connected()
+++ _mssql.MSSQLConnection.clear_metadata()
+++ _mssql.MSSQLConnection.format_sql_command()
+++ _mssql.MSSQLConnection.get_result()
+++ _mssql.MSSQLConnection.clear_metadata()
+++ _mssql.MSSQLConnection.get_header()
+++ _mssql.MSSQLConnection.get_result()
+++ _mssql.MSSQLConnection.get_header()
+++ _mssql.MSSQLConnection.get_result()
+++ _mssql.assert_connected()
+++ _mssql.assert_connected()
+++ _mssql.MSSQLConnection.fetch_next_row_dict()
+++ _mssql.MSSQLConnection.fetch_next_row()
+++ _mssql.MSSQLConnection.get_result()
+++ _mssql.MSSQLConnection.get_row()
Processing row 52, column 1,Got data=313e620, coltype=56, len=4
+++ _mssql.MSSQLConnection.convert_db_value()
Processing row 52, column 2,Got data=313e628, coltype=61, len=8
+++ _mssql.MSSQLConnection.convert_db_value()
Traceback (most recent call last):
File "/home/rsyring/dev/customers/pai/paiauth-venv/bin/nosetests", line 8, in
load_entry_point('nose==1.0.0', 'console_scripts', 'nosetests')()
File "/home/rsyring/dev/customers/pai/paiauth-venv/lib/python2.6/site-packages/nose/core.py", line 118, in init
*_extra_args)
File "/usr/lib/python2.6/unittest.py", line 816, in init
self.parseArgs(argv)
File "/home/rsyring/dev/customers/pai/paiauth-venv/lib/python2.6/site-packages/nose/core.py", line 135, in parseArgs
self.config.configure(argv, doc=self.usage())
File "/home/rsyring/dev/customers/pai/paiauth-venv/lib/python2.6/site-packages/nose/config.py", line 330, in configure
self.plugins.begin()
File "/home/rsyring/dev/customers/pai/paiauth-venv/lib/python2.6/site-packages/nose/plugins/manager.py", line 94, in call
return self.call(_arg, *_kw)
File "/home/rsyring/dev/customers/pai/paiauth-venv/lib/python2.6/site-packages/nose/plugins/manager.py", line 162, in simple
result = meth(_arg, *_kw)
File "/home/rsyring/dev/blaze/web-venv/src/default/blazeweb/nose_plugin.py", line 89, in begin
signal('blazeweb.pre_test_init').send()
File "build/bdist.linux-x86_64/egg/blinker/base.py", line 220, in send
File "/home/rsyring/dev/blaze/sabwc-src/default/sqlalchemybwc/events.py", line 7, in setup_db_structure
run_tasks(settings.components.sqlalchemy.pre_test_init_tasks)
File "/home/rsyring/dev/blaze/web-venv/src/default/blazeweb/tasks.py", line 99, in run_tasks
callable_retval = call_tuple2
File "", line 2, in action_30_base_data
File "/home/rsyring/dev/blaze/web-venv/src/default/blazeweb/tasks.py", line 9, in _attributes
return f(args, **kwargs)
File "/home/rsyring/dev/customers/pai/paiauth-venv/src/paiauth-dist/paicore/tasks/init_db.py", line 14, in action_30_base_data
paicsa_app = Application.get_or_create('paicsa')
File "/home/rsyring/dev/customers/pai/paiauth-venv/src/paiauth-dist/paicore/components/auth/model/orm.py", line 51, in get_or_create
settings.app_ids[abbr] = app.id
File "/home/rsyring/dev/customers/pai/paiauth-venv/lib/python2.6/site-packages/sqlalchemy/orm/attributes.py", line 168, in get
instance_dict(instance))
File "/home/rsyring/dev/customers/pai/paiauth-venv/lib/python2.6/site-packages/sqlalchemy/orm/attributes.py", line 388, in get
value = callable
(passive=passive)
File "/home/rsyring/dev/customers/pai/paiauth-venv/lib/python2.6/site-packages/sqlalchemy/orm/state.py", line 287, in call
self.manager.deferred_scalar_loader(self, toload)
File "/home/rsyring/dev/customers/pai/paiauth-venv/lib/python2.6/site-packages/sqlalchemy/orm/mapper.py", line 2492, in _load_scalar_attributes
only_load_props=attribute_names)
File "/home/rsyring/dev/customers/pai/paiauth-venv/lib/python2.6/site-packages/sqlalchemy/orm/query.py", line 1958, in _get
return q.one()
File "/home/rsyring/dev/customers/pai/paiauth-venv/lib/python2.6/site-packages/sqlalchemy/orm/query.py", line 1646, in one
ret = list(self)
File "/home/rsyring/dev/customers/pai/paiauth-venv/lib/python2.6/site-packages/sqlalchemy/orm/query.py", line 1791, in instances
fetch = cursor.fetchall()
File "/home/rsyring/dev/customers/pai/paiauth-venv/lib/python2.6/site-packages/sqlalchemy/engine/base.py", line 2498, in fetchall
l = self.process_rows(self._fetchall_impl())
File "/home/rsyring/dev/customers/pai/paiauth-venv/lib/python2.6/site-packages/sqlalchemy/engine/base.py", line 2465, in _fetchall_impl
return self.cursor.fetchall()
File "pymssql.pyx", line 436, in pymssql.Cursor.fetchall (pymssql.c:5453)
type(r) == int]) for row in self._source._conn]
File "_mssql.pyx", line 331, in _mssql.MSSQLRowIterator.next (_mssql.c:2979)
return self.conn.fetch_next_row_dict(1)
File "_mssql.pyx", line 891, in _mssql.MSSQLConnection.fetch_next_row_dict (_mssql.c:8276)
row = self.fetch_next_row(throw)
File "_mssql.pyx", line 884, in _mssql.MSSQLConnection.fetch_next_row (_mssql.c:8203)
return self.get_row(rtc)
File "_mssql.pyx", line 1034, in _mssql.MSSQLConnection.get_row (_mssql.c:9441)
record += (self.convert_db_value(data, col_type, len),)
File "_mssql.pyx", line 619, in _mssql.MSSQLConnection.convert_db_value (_mssql.c:5502)
return datetime.datetime(di.year, di.month, di.day,
ValueError: day is out of range for month

Original issue: http://code.google.com/p/pymssql/issues/detail?id=39

Support Hostname, Port, TDS Version in connection options

From [email protected] on April 12, 2011 11:23:03

It would be preferable to avoid the freetds.conf file altogether and to be able to set the port and TDS version. My implementation and and tests are here: https://bitbucket.org/rsyring/pymssql/changeset/4f53623a6308 which handles _mssql.connect() but pymssql.connect() would need to be adjusted to handle the extra params and pass them through too.

Original issue: http://code.google.com/p/pymssql/issues/detail?id=43

All Zip Files are Corrupt

From bluedragonx on April 13, 2010 14:48:00

What steps will reproduce the problem? 1. Download any zip file from "Downloads".
2. Attempt to unzip.
3. Bash head on keyboard. What is the expected output? What do you see instead? I expect the file to unzip. However, the zip files are all obviously
incomplete as they are less than 1kb. What version of the product are you using? On what operating system? 1.9.906 Please provide any additional information below. Don't upload broken zipfiles.

Original issue: http://code.google.com/p/pymssql/issues/detail?id=1

rowcount does not work

From michele.simionato on July 01, 2010 02:22:45

I have just tried on Linux with pymssql-1.9.908 the following script:

from pymssql import connect

CREATE = 'CREATE TABLE foo(i INTEGER PRIMARY KEY, t VARCHAR(100))'
DROP = 'DROP TABLE foo'
INSERT = 'INSERT INTO foo VALUES (%d, %s)'
UPDATE = 'UPDATE foo SET t=%s WHERE i=%d'
SELECT = 'SELECT * FROM foo'
DELETE = 'DELETE FROM foo'

def main():
conn = connect('itdbserver2', 'python', 'p1tone', 'data_manag')
curs = conn.cursor()
curs.execute(CREATE)
try:
curs.execute(INSERT, (1, 'line1'))
print 'INSERT', curs.rowcount
curs.execute(UPDATE, ('line1', 1))
print 'UPDATE', curs.rowcount
curs.execute(SELECT)
print curs.fetchall()
print 'SELECT', curs.rowcount
curs.execute(DELETE)
print 'DELETE', curs.rowcount
finally:
curs.execute(DROP)

I get:

INSERT 0
UPDATE 0
[(1, 'line1')]
SELECT 1
DELETE 0

In other words, the rowcount after INSERT, UPDATE and DELETE is always 0
and this is wrong :-(

Original issue: http://code.google.com/p/pymssql/issues/detail?id=10

VARCHAR type only retrieves the first 255 characters

From offsound on June 24, 2010 14:16:25

What steps will reproduce the problem? 1. Query a table that has a varchar column defined with more than 255 characters.

What is the expected output?
The entire string (up to 8000 characters according to MSSQL specs) that is stored in the varchar column.

What do you see instead?
I only see the first 255 characters. What version of the product are you using? On what operating system? pymssql-1.9.908.win32-py2.6.exe (Windows xp with SQL Server 2005) Please provide any additional information below. I'm not sure if this is like this by design, but I'm pretty certain SQL Server 2005+ supports up to 8000 characters in varchar fields. I don't have access to a SQL 2000 server.

Source: http://msdn.microsoft.com/en-us/library/ms176089.aspx

Original issue: http://code.google.com/p/pymssql/issues/detail?id=9

Build failures on Windows XP 64-bit

From Sridhar.Ratna on July 09, 2010 17:21:28

python setup.py install
running install

running build

running build_ext

extracting FreeTDS

cythoning _mssql.pyx to _mssql.c

building '_mssql' extension

creating build

creating build\temp.win-amd64-2.6

creating build\temp.win-amd64-2.6\Release

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Iwin32\freetds\include -Ic:\python26\include -Ic:\python26\PC /Tc_mssql.c /Fobuild\temp.win-amd64-2.6\Release_mssql.obj -DMSDBLIB

_mssql.c

_mssql.c(643) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'long', possible loss of data

_mssql.c(663) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'long', possible loss of data

_mssql.c(685) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'long', possible loss of data

_mssql.c(712) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'long', possible loss of data

_mssql.c(6192) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data

_mssql.c(9967) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data

c:\documents and settings\apy\local settings\temp\tmp8f1jrn\pymssql-1.9.908_mssql.c(4652) : warning C4700: uninitialized local variable '__pyx_v_dbcol' used

creating build\lib.win-amd64-2.6

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:win32\freetds\lib /LIBPATH:c:\python26\libs /LIBPATH:c:\python26\PCbuild\amd64 msvcrt.lib kernel32.lib user32.lib gdi32.lib winspool.lib ws2_32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libTDS.lib dblib.lib /EXPORT:init_mssql build\temp.win-amd64-2.6\Release_mssql.obj /OUT:build\lib.win-amd64-2.6_mssql.pyd /IMPLIB:build\temp.win-amd64-2.6\Release_mssql.lib /MANIFESTFILE:build\temp.win-amd64-2.6\Release_mssql.pyd.manifest

_mssql.obj : warning LNK4197: export 'init_mssql' specified multiple times; using first specification

Creating library build\temp.win-amd64-2.6\Release_mssql.lib and object build\temp.win-amd64-2.6\Release_mssql.exp

_mssql.obj : error LNK2019: unresolved external symbol dbsqlexec referenced in function __pyx_f_6_mssql_db_sqlexec

_mssql.obj : error LNK2019: unresolved external symbol dbadata referenced in function __pyx_f_6_mssql_get_data

_mssql.obj : error LNK2019: unresolved external symbol dbdata referenced in function __pyx_f_6_mssql_get_data

_mssql.obj : error LNK2019: unresolved external symbol dbalttype referenced in function __pyx_f_6_mssql_get_type

_mssql.obj : error LNK2019: unresolved external symbol dbcoltype referenced in function __pyx_f_6_mssql_get_type

_mssql.obj : error LNK2019: unresolved external symbol dbadlen referenced in function __pyx_f_6_mssql_get_length

_mssql.obj : error LNK2019: unresolved external symbol dbdatlen referenced in function __pyx_f_6_mssql_get_length

_mssql.obj : error LNK2019: unresolved external symbol dbcancel referenced in function __pyx_f_6_mssql_db_cancel

_mssql.obj : error LNK2019: unresolved external symbol dbtds referenced in function pyx_pf_6_mssql_15MSSQLConnection_11tds_version___get

_mssql.obj : error LNK2019: unresolved external symbol dbclose referenced in function __pyx_pf_6_mssql_15MSSQLConnection_close

_mssql.obj : error LNK2019: unresolved external symbol dbuse referenced in function __pyx_pf_6_mssql_15MSSQLConnection_select_db

_mssql.obj : error LNK2019: unresolved external symbol dbgetmaxprocs referenced in function __pyx_pf_6_mssql_get_max_connections

_mssql.obj : error LNK2019: unresolved external symbol dbcount referenced in function __pyx_f_6_mssql_15MSSQLConnection_execute_scalar

_mssql.obj : error LNK2019: unresolved external symbol dbnextrow referenced in function __pyx_f_6_mssql_15MSSQLConnection_execute_scalar

_mssql.obj : error LNK2019: unresolved external symbol dbsettime referenced in function pyx_pf_6_mssql_15MSSQLConnection_13query_timeout___set

_mssql.obj : error LNK2019: unresolved external symbol dbcmd referenced in function pyx_pf_6_mssql_15MSSQLConnection___init

_mssql.obj : error LNK2019: unresolved external symbol dbloginfree referenced in function pyx_pf_6_mssql_15MSSQLConnection___init

_mssql.obj : error LNK2019: unresolved external symbol tdsdbopen referenced in function pyx_pf_6_mssql_15MSSQLConnection___init

_mssql.obj : error LNK2019: unresolved external symbol dbsetlogintime referenced in function pyx_pf_6_mssql_15MSSQLConnection___init

_mssql.obj : error LNK2019: unresolved external symbol dbsetlname referenced in function pyx_pf_6_mssql_15MSSQLConnection___init

_mssql.obj : error LNK2019: unresolved external symbol dblogin referenced in function pyx_pf_6_mssql_15MSSQLConnection___init

_mssql.obj : error LNK2019: unresolved external symbol dbdatecrack referenced in function __pyx_f_6_mssql_15MSSQLConnection_convert_db_value

_mssql.obj : error LNK2019: unresolved external symbol dbconvert referenced in function __pyx_f_6_mssql_15MSSQLConnection_convert_db_value

_mssql.obj : error LNK2019: unresolved external symbol dbresults referenced in function __pyx_f_6_mssql_15MSSQLConnection_execute_non_query

_mssql.obj : error LNK2019: unresolved external symbol dbrpcinit referenced in function pyx_pf_6_mssql_20MSSQLStoredProcedure___init

_mssql.obj : error LNK2019: unresolved external symbol dbrpcparam referenced in function __pyx_pf_6_mssql_20MSSQLStoredProcedure_bind

_mssql.obj : error LNK2019: unresolved external symbol dbretstatus referenced in function __pyx_pf_6_mssql_20MSSQLStoredProcedure_execute

_mssql.obj : error LNK2019: unresolved external symbol dbretdata referenced in function __pyx_pf_6_mssql_20MSSQLStoredProcedure_execute

_mssql.obj : error LNK2019: unresolved external symbol dbretlen referenced in function __pyx_pf_6_mssql_20MSSQLStoredProcedure_execute

_mssql.obj : error LNK2019: unresolved external symbol dbretname referenced in function __pyx_pf_6_mssql_20MSSQLStoredProcedure_execute

_mssql.obj : error LNK2019: unresolved external symbol dbrettype referenced in function __pyx_pf_6_mssql_20MSSQLStoredProcedure_execute

_mssql.obj : error LNK2019: unresolved external symbol dbnumrets referenced in function __pyx_pf_6_mssql_20MSSQLStoredProcedure_execute

_mssql.obj : error LNK2019: unresolved external symbol dbsqlok referenced in function __pyx_pf_6_mssql_20MSSQLStoredProcedure_execute

_mssql.obj : error LNK2019: unresolved external symbol dbrpcsend referenced in function __pyx_pf_6_mssql_20MSSQLStoredProcedure_execute

_mssql.obj : error LNK2019: unresolved external symbol dbsetmaxprocs referenced in function __pyx_pf_6_mssql_set_max_connections

_mssql.obj : error LNK2019: unresolved external symbol dbmsghandle referenced in function __pyx_f_6_mssql_init_mssql

_mssql.obj : error LNK2019: unresolved ...

Original issue: http://code.google.com/p/pymssql/issues/detail?id=11

Exception messages are corrupted

From [email protected] on April 12, 2011 11:20:24

What steps will reproduce the problem?

Deliberately make a connection to a server that doesn't have a MSSQL server running or change the port to a wrong port. However, you need to use a hostname that exists, or you will get a different error.

What is the expected output?

MSSQLDatabaseException: (20009, 'Net-Lib error during Connection refused')

What do you see instead?

MSSQLDatabaseException: (20009, '\xe8u\xbd*{\x7f')

I was also seeing:

Exception TypeError: 'an integer is required' in '_mssql.err_handler' ignored

come through to the terminal. What version of the product are you using? On what operating system? SVN / Ubuntu 10.04 Please provide any additional information below. Looks like it is a problem with the way error strings are being copied into C variables. My solution is here: https://bitbucket.org/rsyring/pymssql/changeset/e68f2d8425ba But, this is also related to issue 41 .

Original issue: http://code.google.com/p/pymssql/issues/detail?id=42

Co-ordinate with SQLAlchemy team on workarounds/limitations

From [email protected] on April 12, 2011 16:07:13

SQLAlchemy is aware of limitations for 1.x branch: http://www.sqlalchemy.org/docs/dialects/mssql.html#limitations and their dialect classes actually enforce at least one of these (30 char identifiers). We need to communicate with SA team and maybe even offer patches once we stabilize 2.0 code so that pymssql isn't artificially hindered by SA.

Original issue: http://code.google.com/p/pymssql/issues/detail?id=44

ZipFile don't has the attribute 'extractall' error for python2.5

From shixiangwen03 on June 18, 2010 08:32:50

What steps will reproduce the problem? 1. python setup.py install 2. 3. What is the expected output? What do you see instead? AttributeError: ZipFile instance has no attribute 'extractall' What version of the product are you using? On what operating system? windows xp, python2.5 Please provide any additional information below. in pythoon2.5 ZipFile don't has the attribute 'extractall',

from zipfile import ZipFile
dir(ZipFile)
['_GetContents', '_RealGetContents', 'del', 'doc', 'init', '__module
__', '_writecheck', 'close', 'fp', 'getinfo', 'infolist', 'namelist', 'printdir'
, 'read', 'testzip', 'write', 'writestr']

Original issue: http://code.google.com/p/pymssql/issues/detail?id=8

connection error with unknown reason on Windows

From [email protected] on April 17, 2011 23:33:11

What steps will reproduce the problem? 1. install tdm-gcc 4.5.2 32bit version from http://tdm-gcc.tdragon.net/download 2. clone 7a55159b409b revision
3 . modify setup.py as below
if sys.platform == 'win32':
WINDOWS = True
WIN32 = os.path.join(ROOT, 'win32')
FREETDS = os.path.join(WIN32, 'freetds')
include_dirs = [os.path.join(FREETDS, 'include')]
library_dirs = [os.path.join(FREETDS, 'lib')]
libraries = [
#'libiconv', # <<< comment
#'iconv', # <<< comment
'sybdb',
'ws2_32',
'wsock32',
'kernel32',
]
4. build and install the pymssql
python26 setup.py build -c mingw32 bdist_wininst

  1. run the following script.
    import pymssql
    conn = pymssql.connect(server="myserver",
    user="myid", password="mypw", database="mydb")
    cur = conn.cursor()
    cur.execute("select * from mytable")

for row in cur:
print row What is the expected output? What do you see instead? It is expected that contents of table is printed.
But, below error message occurred.

D:\prj\secu\TestWork\pymssql>python26 testpymssql.py
Traceback (most recent call last):
File "testpymssql.py", line 4, in
user="tsaver", password="tsaveradmin", database="tsaver")
File "pymssql.pyx", line 519, in pymssql.connect (pymssql.c:6697)
raise InterfaceError(e[0])
pymssql.InterfaceError: Connection to the database failed for an unknown reason. What version of the product are you using? On what operating system? revision 7a55159b409b , Cython 0.14.1, Python 2.6.6, Windows 7 Please provide any additional information below. Above script worked in CentOS 5.5 32bit well.
Also rev 237 build don't produce this issue on Windows.

Original issue: http://code.google.com/p/pymssql/issues/detail?id=48

Cursor.fetchall() returns None when as_dict=True

From [email protected] on June 16, 2010 08:27:09

What steps will reproduce the problem? 1. Create a connection with as_dict=True argument
2. Create a cursor and execute a query
3. Call cursor's fetchall() method What is the expected output? What do you see instead? Should return a list of zero or more dicts but returns None instead. What version of the product are you using? On what operating system? pymssql-1.9.908 on Mac OS X 10.5.8 Please provide any additional information below. Patch attached.

Attachment: pymssql.diff

Original issue: http://code.google.com/p/pymssql/issues/detail?id=7

Feature Request: Option to return namedtuple (patch included)

From [email protected] on March 24, 2011 21:47:03

Just watch R Hettinger's pycon video where he talks about namedtuple (collections.namedtuple) It would be great if you added this as an option like 'asdict'.

Since you can build the dict, you have all the information to create a namedtuple. http://docs.python.org/library/collections.html#collections.namedtuple There are a lot of pluses, like better memory usage like a regular tuple, plus self documenting. We would get the best of both worlds of tuples and dicts.

Original issue: http://code.google.com/p/pymssql/issues/detail?id=38

better handling for byte strings that don't represent ascii data

From [email protected] on April 15, 2011 14:42:40

I have a test:

test_sqlalchemy:TestSA.test_pickle_type

that fails currently. When this column is created, it is created as a varchar(50) column. There is a note and monkey patch in:

sqlalchemy.dialects.mssql.pymssql.MSDialect_pymssql.dbapi

referring to the fact that pymssql does not have a Binary method. I am a little over my head on this one as to what we need to do to fix it.

Original issue: http://code.google.com/p/pymssql/issues/detail?id=46

running against CVS version of FreeTDS fails

From [email protected] on April 07, 2011 07:35:45

I downloaded a copy of FreeTDS from CVS, built it, and then compiled pymssql. When running a simple test script, I get:

File "_mssql.pyx", line 477, in _mssql.MSSQLConnection.init (_mssql.c:4092)
raise MSSQLDriverException("Connection to the database failed for an unknown reason.")
_mssql.MSSQLDriverException: Connection to the database failed for an unknown reason.

I can run the same test script with the FreeTDS version that ships with Ubuntu 10.04.

Original issue: http://code.google.com/p/pymssql/issues/detail?id=40

Pymssql mishandles bigint indexes greater than 24 bits.

From eric.woudenberg on June 08, 2010 09:39:29

What steps will reproduce the problem? 1. Create table "test_index" with one bigint column "id"
2. Execute SQL: insert into test_index (id) values (123456789)
3. Execute this python program:

import _mssql
conn = _mssql.connect(server=DB_Server, user=DB_user, password=DB_password, database=Database)
id = 123456789
print 'Selecting id = ', id
conn.execute_query('SELECT * FROM test_index WHERE id = %s', id)
for row in conn:
print "ID=%s\n" % row['id']

What is the expected output?

LogSrv1$ ./try.py
Selecting id = 123456789
ID=123456789.0

What do you see instead?

LogSrv1$ ./try.py
Selecting id = 123456789
ID=123456792.0 What version of the product are you using? On what operating system? /Python26/lib/site-packages/pymssql-1.9.905.1-py2.6.egg-info/
Microsoft Windows Server 2003 R2 Please provide any additional information below. Thank you for looking at this and/or suggesting a workaround!

Original issue: http://code.google.com/p/pymssql/issues/detail?id=5

need new releases on PYPI

From akimov.alex on June 09, 2010 00:32:21

What steps will reproduce the problem? $ sudo easy_install pymssql
Searching for pymssql
Reading http://pypi.python.org/simple/pymssql/ Reading http://pymssql.sourceforge.net Reading http://sourceforge.net/project/showfiles.php?group_id=40059&package_id=32202 Reading http://code.google.com/p/pymssql/ Reading http://code.google.com/p/pymssql/downloads/list Best match: pymssql 1.9.908.win32
Downloading http://pymssql.googlecode.com/files/pymssql-1.9.908.win32.zip Processing pymssql-1.9.908.win32.zip
error: Couldn't find a setup script in /tmp/easy_install-s3UIdY/pymssql-1.9.908.win32.zip What version of the product are you using? On what operating system? Kubuntu 10.04 Please provide any additional information below. Maybe this is not correct place for this bug, then I hope you'll help me and tell where to post it. (I don't known much about easy_install)

Original issue: http://code.google.com/p/pymssql/issues/detail?id=6

A way to get pymssql to use FreeTDS build from a virtualenv?

I work on pymssql inside a virtualenv where along all the development/building/testing dependencies I've also installed FreeTDS.

I use FreeTDS from the post 0.91 Git branch, this way I get a version that

  • Has additional fixes over stable 0.91 and the FreeTDS bundled with pymssql but
  • Isn't unstable like their master branch code.

Given that such version isn't available from Linux distributors packages and that it is good to be able to do this work without being root, it seems natural to build it myself and furthermore have it installed to <virtualenv>/lib and <virtualenv>/include instead of /usr/local/...

BTW, this is easily achievable with something like (from <virtualenv>/src/freeedts/freetds-x.x.x):

$ ./configure --with-tdsver=7.1 --disable-server --disable-pool --disable-odbc --enable-msdblib --enable-sspi --with-gnutls --prefix=${PWD}/../../..
$ make
$ make install

Now when it comes to build pymssql the choices currently available are:

  1. Use the bundled FreeTDS (python setup.py develop).
  2. Lookup system-wide paths:
$ PYMSSQL_DONT_BUILD_WITH_BUNDLED_FREETDS=1 python setup.py develop
[...]
setup.py: include_dirs = ['/usr/local/include', '/usr/local/freetds/include']
setup.py: library_dirs = ['/usr/local/lib', '/usr/local/freetds/lib']

But there is no way to get a custom, intermediate FreeTDS location option. I've achieved what I want by patching setup.py to prepend my virtualenv paths to include_dirs and library_dirs.

gcc environment vars (http://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html) can't be of help here because their precedence is lower to paths specified in the command line.

Import of pymssql on Centos fails to find libsydbd.so.5

From clwaters on May 14, 2010 16:57:31

What steps will reproduce the problem? 1. Build from current source 1.9.908
2. import pymssql; What is the expected output? What do you see instead? Python 2.6.5 ( r265 :79063, May 14 2010, 12:02:51)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import pymssql;
Traceback (most recent call last):
File "", line 1, in
ImportError: libsybdb.so.5: cannot open shared object file: No such file or
directory What version of the product are you using? On what operating system? 1.9.908
CentOS release 5.4 (Final)
Linux centreon 2.6.18-164.15.1.el5 #1 SMP Wed Mar 17 11:30:06 EDT 2010
x86_64 x86_64 x86_64 GNU/Linux Please provide any additional information below. This is for python2.6 which was built from source using the make altinstall
build command so that it may live side by side with the default 2.4 that
comes with CentOs. That seems to work fine as other modules can be
imported without error.

Tried to follow the README to build pymssql but it seems incomplete. Ran
/path/to/python2.6 setup.py build. README suggests there should be a tests
directory that does not see to be created. Then ran /path/to/python2.6
setup.py install. This seems to place the files in the correct location
for that build.

It appears that although setup.py looks in the /usr/local/lib dir as part
of the include process, it's not being honored. A symbolic link to
/usr/lib64 for /usr/local/lib/libsybdb.so.5 corrects the issue.

Original issue: http://code.google.com/p/pymssql/issues/detail?id=4

feature: more detailed exceptions

From [email protected] on April 12, 2011 11:07:48

When doing some debugging/testing, I noticed the following was output:

*** err_handler(dbproc = 0x22f28c0, severity = 9, dberr = 20009, oserr = 111, dberrstr = 'Unable to connect: Adaptive Server is unavailable or does not exist', oserrstr = 'Connection refused'); DBDEAD(dbproc) = 1
*** previous max severity = 0

This comes through to the Python developer as:

File "_mssql.pyx", line 1349, in _mssql.maybe_raise_MSSQLDatabaseException (_mssql.c:12321)
raise ex
MSSQLDatabaseException: (20009, 'Net-Lib error during Connection refused')

However, that message is pretty unhelpful to the python dev who doesn't understand the 20009 code/message is coming from TDS and/or doesn't know what to do with it.

In order to make the messages less cryptic and more helpful, I would like to suggest making the string representation of a MSSQLException look something like:

DB: '', OS: '', tdscode: , tdsmsg: ''

So, the above exception would come through as:

MSSQLDatabaseException: DB: 'Unable to connect: Adaptive Server is unavailable or does not exist', OS: 'Connection refused', tdscode: 20009, tdsmsg: 'Net-Lib error during Connection refused'

Original issue: http://code.google.com/p/pymssql/issues/detail?id=41

_mssql.c: No such file or directory

From mbroadh2o on April 28, 2010 17:00:10

What steps will reproduce the problem? 1. Download pymssql-1.9.908.tar.gz
2. Try and build
3. Receive build error -> no _myssql.c
4. Pre-reqs are installed What is the expected output? What do you see instead? A clean build What version of the product are you using? On what operating system? 1.9.908 on RedHat 2.6.9-67.ELsmp Please provide any additional information below. I've also tried this with an earlier source release 1.9.907 and the result
was the same. Below is a snippet from the actual output:

sr/pkg/freetds/include -I/usr/local/include/python2.6 -c _mssql.c -o
build/temp.linux-i686-2.6/_mssql.o -DMSDBLIB
gcc: _mssql.c: No such file or directory
gcc: no input files
error: command 'gcc' failed with exit status 1

Below are the directory contents:

build MANIFEST.in pymssql.egg-info setuptools-0.6c11-py2.6.egg
ChangeLog _mssql.pxd pymssql.pyx sqlfront.pxd
ez_setup.py _mssql.pyx README win32
ez_setup.pyc nagios-plugin setup.cfg
LICENSE PKG-INFO setup.py

Original issue: http://code.google.com/p/pymssql/issues/detail?id=3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.