what I can do for the moment is this patch, if you want to try it:
diff -r 17cab4ad55d5 lib/sqlalchemy/dialects/mssql/pymssql.py
--- a/lib/sqlalchemy/dialects/mssql/pymssql.py Thu Oct 04 18:26:55 2012 -0400
+++ b/lib/sqlalchemy/dialects/mssql/pymssql.py Fri Oct 05 18:46:01 2012 -0400
@@ -80,7 +80,7 @@
def _get_server_version_info(self, connection):
vers = connection.scalar("select @@version")
m = re.match(
- r"Microsoft SQL Server.*? - (\d+).(\d+).(\d+).(\d+)", vers)
+ r"\s*Microsoft SQL Server.*? - (\d+).(\d+).(\d+).(\d+)", vers)
if m:
return tuple(int(x) for x in m.group(1, 2, 3, 4))
else:
otherwise, I'd consider using pyodbc for which the dialect and DBAPI are
production quality. I use pyodbc with FreeTDS on unix platforms in production.
On Oct 5, 2012, at 1:40 PM, [email protected] wrote:
> Hello.
>
>> I dont have easy access to pymssql here so can you fully define what "fails"
>> means ? stack trace ?
>
> I don't have access to my development environment during the weekend, so I
> cannot provide you with a stacktrace, but I try to better describe the issue:
>
> def _get_server_version_info(self, connection)
> vers = connection.scalar("select @@version")
> m = re.match(r"Microsoft SQL Server.*? - (\d+).(\d+).(\d+).(\d+)",
> vers)
> ...
>
> The above code snippet is from the file pymssql (around line 80). The
> variable vers is set to None and because of that the following regex fails
> with error "Expected string or buffer". The None is returned by the call to
> scalar(). The code snippet (from memory, I don't remember its exact location
> and form):
>
> iter(resultproxy).next()
>
> is called to get a next (first) result from the result proxy and it simply
> returns None as if there were no rows.
>
> Ladislav Lenart
>
>
> Od: "Michael Bayer" <[email protected]>
>> On Oct 5, 2012, at 9:40 AM, Ladislav Lenart wrote:
>>
>>> Hello.
>>>
>>> I try to access a Microsoft SQL database from Linux (Debian testing):
>>>
>>> from sqlalchemy.ext.sqlsoup import SqlSoup
>>>
>>> conn_string = 'mssql+pymssql://user:pass@freetds_name'
>>> db = SqlSoup(conn_string)
>>> v = db.some_table.first()
>>> print v
>>>
>>> freetds_name is the section name from /etc/freetds/freetds.conf
>>>
>>> [freetds_name]
>>> host = ...
>>> port = 1433
>>> tds version = 7.1
>>> asa database = DB
>>>
>>> The above script fails
>>
>>
>> I dont have easy access to pymssql here so can you fully define what "fails"
>> means ? stack trace ?
>>
>>
>>
>>
>>> in pymssql on line 83, because line 81 sets vers to None:
>>>
>>> def _get_server_version_info(self, connection):
>>> vers = connection.scalar("select @@version")
>>> m = re.match(
>>> r"Microsoft SQL Server.*? - (\d+).(\d+).(\d+).(\d+)", vers)
>>> if m:
>>> return tuple(int(x) for x in m.group(1, 2, 3, 4))
>>> else:
>>> return None
>>>
>>> But the following works in tsql:
>>>
>>> 1> select @@version
>>> 2> go
>>>
>>> Microsoft SQL Server 2008 R2 (RTM) - 10.50.1617.0 (X64)
>>> Apr 22 2011 19:23:43
>>> Copyright (c) Microsoft Corporation
>>> Workgroup Edition (64-bit) on Windows NT 6.1 <X64>
>>> (Build 7601: Service Pack 1) (Hypervisor)
>>>
>>> (1 row affected)
>>>
>>>
>>> Any idea what is wrong?
>>>
>>>
>>> Thank you,
>>>
>>> Ladislav Lenart
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "sqlalchemy" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/sqlalchemy?hl=en.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sqlalchemy" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/sqlalchemy?hl=en.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.