I have a strange problem with pymssql 1.0.1. My query gets truncated and SQL Server complains about syntax errors. The same code (shown at the end of the message) works fine with pymssql 0.8.0.
Furthermore the code works if I add some imports before and after 'import pymssql' line, i.e.
import sys
import pymssql
import os
And it works!? What's happening here? However adding any class definition to the same file breaks the code again...
Some debugging information: debug_queries prints OK query, no missing or additional characters there. But in freetds log there is:
dblib.c:1243:dbcmd(0x81edcc0, SELECT ...OK Here ...1-4101-BC9C-E50A542A5CA7'); ¨^A)
Where did those characters after semicolon came from? And then it continues:
write.c:136:tds_put_string converting 385 bytes of " SELECT ...OK...1-4101-BC9C-E50A^Q"
Which, of course, is wrong and invalid SQL since closing quatation mark and parenthesis are missing.
Both versions of pymssql are compiled in this machine (x86, ubuntu 8.04) and freetds (0.82) is compiled from source .deb.
I think this might be related to character encoding, my code is utf-8, in freetds.conf I have: tds version=8.0, client charset=UTF-8 and locale is "en_US.UTF-8"
Any ideas what's going on?
And finally the code:
<code>
import pymssql
con = pymssql.connect(host='1.2.3.4:1433\SOFT', user='X', password='Y',
database='db1')
cur=con.cursor()
lastSeenGuid="6ACEB2A2-D461-4101-BC9C-E50A542A5CA7"
query = r"""SELECT Headers.ID, Headers.Comment,
Headers.CashierCode,
Headers.TranTimeStamp AS
TimeStamp,
Rows.RowItemCode AS
ItemCode
FROM dbo.tblTillHeaders AS Headers INNER JOIN
dbo.tblTillRows AS Rows ON
Headers.ID=Rows.HeaderGUID
WHERE Rows.RowItemCode > %d AND Headers.TranTimeStamp >
( SELECT TranTimeStamp FROM
dbo.tblTillHeaders
WHERE dbo.tblTillHeaders.ID = %s)"""
cur._source.debug_queries=True
cur.execute(query,(0,str(lastSeenGuid)))
print cur.fetchall()
</code>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This issue is already fixed in CVS. If you can pull it and compile yourself, you don't have to wait for 1.0.2 release. I have applied almost all patches and bugfixes and done limited testing, so it should be in pretty good shape. Any feedback is welcome.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a strange problem with pymssql 1.0.1. My query gets truncated and SQL Server complains about syntax errors. The same code (shown at the end of the message) works fine with pymssql 0.8.0.
Furthermore the code works if I add some imports before and after 'import pymssql' line, i.e.
import sys
import pymssql
import os
And it works!? What's happening here? However adding any class definition to the same file breaks the code again...
Some debugging information: debug_queries prints OK query, no missing or additional characters there. But in freetds log there is:
dblib.c:1243:dbcmd(0x81edcc0, SELECT ...OK Here ...1-4101-BC9C-E50A542A5CA7'); ¨^A)
Where did those characters after semicolon came from? And then it continues:
write.c:136:tds_put_string converting 385 bytes of " SELECT ...OK...1-4101-BC9C-E50A^Q"
Which, of course, is wrong and invalid SQL since closing quatation mark and parenthesis are missing.
Both versions of pymssql are compiled in this machine (x86, ubuntu 8.04) and freetds (0.82) is compiled from source .deb.
I think this might be related to character encoding, my code is utf-8, in freetds.conf I have: tds version=8.0, client charset=UTF-8 and locale is "en_US.UTF-8"
Any ideas what's going on?
And finally the code:
<code>
import pymssql
con = pymssql.connect(host='1.2.3.4:1433\SOFT', user='X', password='Y',
database='db1')
cur=con.cursor()
lastSeenGuid="6ACEB2A2-D461-4101-BC9C-E50A542A5CA7"
query = r"""SELECT Headers.ID, Headers.Comment,
Headers.CashierCode,
Headers.TranTimeStamp AS
TimeStamp,
Rows.RowItemCode AS
ItemCode
FROM dbo.tblTillHeaders AS Headers INNER JOIN
dbo.tblTillRows AS Rows ON
Headers.ID=Rows.HeaderGUID
WHERE Rows.RowItemCode > %d AND Headers.TranTimeStamp >
( SELECT TranTimeStamp FROM
dbo.tblTillHeaders
WHERE dbo.tblTillHeaders.ID = %s)"""
cur._source.debug_queries=True
cur.execute(query,(0,str(lastSeenGuid)))
print cur.fetchall()
</code>
This is a bug in pymssql. I am already aware of it. It'll be fixed in 1.0.2. Sorry for the inconvenience.
Thanks for the quick response.
Is there already a patch for that somewhere, in CVS? Or is the best workaround to use version 0.8?
Hi
Has there been any movement on this bug or a date for 1.0.2? I'm running into this as well and it's very annoying.
Cheers
I'll try to do my best to release pymssql 1.0.2 by the end of next week.
Thanks. (I'm running into the same issue...)
I also went into this issue and looking forward to v1.0.2 ...
This issue is already fixed in CVS. If you can pull it and compile yourself, you don't have to wait for 1.0.2 release. I have applied almost all patches and bugfixes and done limited testing, so it should be in pretty good shape. Any feedback is welcome.
Im using v 1.0.2 now and it works like a charm! Thanks!
Good to know. Have fun!
addition to my post:
Screenshot of query within the M$SQL-Profiler
http://twitpic.com/3tlll