[ubuntu-in] Connecting to MSSQL from ubuntu
consoleart
consoleart at gmail.com
Wed Feb 18 04:23:36 GMT 2009
Mehul Ved wrote:
> On Tue, Feb 17, 2009 at 7:08 PM, Consoleart <consoleart at gmail.com> wrote:
>
>> I am now trying to use Phython scripts for connecting to a MSSQL server
>> on my windows server however i am not able to connect .
>>
>
> Have you installed python-pymssql? If not install the package.
>
>
>> when I run my
>> python script it gives the error Server not found,
>> I know that i am
>>
>
> Please post the relevant snippet of code or the whole code.
> Also, post the backtrace of the error. It might contain some important clues.
>
>
here is the code that i use
#!/usr/bin/python
import _mssql
//the error comes in the next line
mssql=_mssql.connect('jagserver','sa','mypassword')
mssql.select_db('dbnamehere')
query="select [maintenance name],[maintenance code] from [maintenance
routines];"
if mssql.query(query):
rows=mssql.fetch_array()
rowNumbers = rows[0][1]
print "Number of rows fetched: " + str(rowNumbers)
for row in rows:
for i in range(rowNumbers):
print str(i) + "\t" + row[2][i][0] + "\t" + row[2][i][1] + "\t"
+ str(row[2][i][2])
else:
print mssql.errmsg()
print mssql.stdmsg()
mssql.close()
and yes i have installed python-pymssql
More information about the ubuntu-in
mailing list