pymssql connect mssql server

842 views
Skip to first unread message

零五

unread,
Sep 26, 2013, 3:54:20 AM9/26/13
to sqlal...@googlegroups.com
hello everyone,

i have a problom with pymssql connect mssql server .please help me to sovle it.thx

code:
connect_str = r"mssql+pymssql://"
connect_str += r"%s:%s@%s:%s/%s?charset=%s" % (self.username, self.password, self.ip, self.port, self.db_name, self.get_encode_display())
    engine = sqlalchemy.create_engine(db_connect_str)
    Session = sqlalchemy.orm.sessionmaker(bind=engine)
    session = Session()
 
    data = session.execute(sql_str)


 backtrack:
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 170, in initialize
    self._get_server_version_info(connection)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/dialects/mssql/pymssql.py", line 72, in _get_server_version_info
    r"Microsoft SQL Server.*? - (\d+).(\d+).(\d+).(\d+)", vers)
  File "/usr/lib/python2.7/re.py", line 137, in match
    return _compile(pattern, flags).match(string)
TypeError: expected string or buffer


i print vers, it's None.

but,i try it in shell,

~$ sqsh -U sa -P 123456 -S 192.168.1.21
1> select @@version
2> go

                                                                                                                   
                                                                                                                       
                      

    ----------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
-----------------------

    Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86)
    Jul  9 2008 14:43:34
    Copyright (c) 1988-2008 Microsoft Corporation
    Enterprise Evaluation Edition on Windows NT 5.1 <X86> (Build 2600: Service Pack 3)
                                        

(1 row affected)

零五

unread,
Sep 26, 2013, 5:58:07 AM9/26/13
to sqlal...@googlegroups.com

Michael Bayer

unread,
Sep 26, 2013, 10:00:11 AM9/26/13
to sqlal...@googlegroups.com
what is the actual SQL Server version there as well as what FreeTDS are you running


On Sep 26, 2013, at 5:58 AM, 零五 <shanqi...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.
To post to this group, send email to sqlal...@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

signature.asc

Michael Bayer

unread,
Sep 26, 2013, 10:16:37 AM9/26/13
to sqlal...@googlegroups.com
this bug report for pymssql is nearing two years old.  Please get a more recent version of pymssql as directed in the comments on that ticket:



apt-get uninstall python-pymssql; pip install pymssql
signature.asc

零五

unread,
Sep 28, 2013, 9:36:12 PM9/28/13
to sqlal...@googlegroups.com
thanks for your answer. i used pip install pymssql   success ,
my english is very bad,...

在 2013年9月26日星期四UTC+8下午10时16分37秒,Michael Bayer写道:
Reply all
Reply to author
Forward
0 new messages