Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #20071

Re: Can not get the result of query in pymssql module of python...

Date 2012-02-09 07:31 -0500
From Rod Person <rodperson@rodperson.com>
Subject Re: Can not get the result of query in pymssql module of python...
References <CAH8cRFCGOu0Fx6_Gn9uLCWr96v9ZPz1gKaAXADitU9thbr-GNA@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.5584.1328791258.27778.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, 9 Feb 2012 12:34:25 +0530
amarjeet yadav <amarjeet.java@gmail.com> wrote:

> Hi All,
>            This is my first post to any mailing group. I am QA engg
> and using python for testing automation. I need to connect with Mysql
> (2008) and mssql databases for executing some queries.
> 
> I have installed following modules & softwares in python 2.7 :
> 
> python 2.7.2
> setuptools
> MySQLdb Module
> pymssql module
> yum install mysql msql-devel freetdf
> 
> I have installed freetds 0.9version. After installation of all the
> above components, I have done following things
> 
> Python 2.6 (r26:66714, Apr  8 2010, 08:46:35)
> [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import pymssql
> >>> conn = pymssql.connect(host='mssql_server', user='_username',
> password='_password', database='_db',as_dict=True)
> >>> cur = conn.cursor()
> >>> cur.execute('select count(*) from D2.dbo.abc (nolock)')
> >>> print cur.fetchall()

What if you change this to 

	print cur.fetchone()

About 95% of my python database work is with MS SQL. I use fetchone when
as_dict is True and it seems to work better for me.

> []
> >>> cur.rowcount
> -1
> >>> exit()
> 
> I am expecting that the result of the query will be 16. But it is not
> retuning any data from query with no error at any place. On execting
> the same query in tsql, I got result as 16.
> 



-- 

Rod Person  http://www.rodperson.com  rodperson@rodperson.com

'Silence is a fence around wisdom'

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Can not get the result of query in pymssql module of python... Rod Person <rodperson@rodperson.com> - 2012-02-09 07:31 -0500

csiph-web