Closed GoogleCodeExporter closed 9 years ago
I apply your patch and test about issue 48.
But, same error occured.
Traceback (most recent call last):
File "D:\prj\secu\TestWork\pymssql\testpymssql.py", line 4, in <module>
user="myid", password="mypw", database="mydb")
File "C:\devtool\py25x86\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.
Original comment by marun...@gmail.com
on 22 Apr 2011 at 6:21
the module fails when you connect to the database using variables, I thought
the error could be that they were not initialized and was filled with other
values, but apparently this bug has been passed down to other database compose
Python such as: pymssql, pymsql, mysqldb _mssql and if that did not solve is
that when information comes from code variables, the module is not managed
properly.
Bug Code Example:
import sys
import _mssql
import array
v = []
file = open("config.infor","r")
i = 0
while True:
row = file.readline()
if not row: break
v.append(row)
srv = v[0]
usr = v[1]
pss = v[2]
dbs = v[3]
conn = _mssql.connect(server=srv, user=usr, password=pss, database=dbs)
try:
SQL = ""
conn.execute_query(SQL)
conn.close()
except _mssql.MssqlDatabaseException, e:
wx.MessageBox ("Error %d: %s" %(e.number,e.message),"Error",wx.OK|wx.ICON_ERROR)
conn.close()
this code launch the error "Connection to the database failed for an unknown
reason.", but when you not use variables the modules works right.
Example:
import sys
import _mssql
conn = _mssql.connect(server="YODA-SERVER\SQLYODA", user="test",
password="123456", database="dbtest")
try:
SQL = ""
conn.execute_query(SQL)
conn.close()
except _mssql.MssqlDatabaseException, e:
wx.MessageBox ("Error %d: %s" %(e.number,e.message),"Error",wx.OK|wx.ICON_ERROR)
conn.close()
I will check the lines they gave you the error to see if I can fix and then you
pass them for you to try
Original comment by YosefEli...@gmail.com
on 22 Apr 2011 at 5:13
Attachments:
I test the following test code on Windows7 with tdm-gcc 4.5.2 build.
import _mssql
conn = _mssql.connect(server="192.168.123.xxxxx",
user="myid", password="mypw", database="mydb")
conn.execute_query("select * from mytable")
conn.close()
This code work well in revision f95f6c0deb8c build.
But, don't work in revision 46fde04e1e45 build and latest(7a55159b409b)
revision build.
Traceback (most recent call last):
File "test_mssql.py", line 3, in <module>
user="tsaver", password="tsaveradmin", database="tsaver")
File "_mssql.pyx", line 1516, in _mssql.connect (_mssql.c:14525)
return MSSQLConnection(*args, **kwargs)
File "_mssql.pyx", line 500, in _mssql.MSSQLConnection.__init__ (_mssql.c:4181
)
raise MSSQLDriverException("Connection to the database failed for an unknown
reason.")
_mssql.MSSQLDriverException: Connection to the database failed for an unknown re
ason.
Same code work well on CentOS 5.6. in latest(7a55159b409b) revision build.
Original comment by marun...@gmail.com
on 25 Apr 2011 at 5:44
> this code launch the error "Connection to the database failed for an unknown
reason.", but when you not use variables the modules works right.
I think your variables don't contain the information you think they do. There
is no reason why pymssql would work differently with variables being passed in
as opposed to strings as in your example. If the default values do not work
for you, you need to pass in explicit arguments.
Original comment by rsyr...@gmail.com
on 25 Apr 2011 at 9:37
Original comment by msabr...@gmail.com
on 23 Sep 2013 at 7:08
Original issue reported on code.google.com by
YosefEli...@gmail.com
on 22 Apr 2011 at 4:13Attachments: