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...

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rodperson@rodperson.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:module': 0.04; 'rod': 0.07; 'sql.': 0.07; 'subject:query': 0.07; 'python': 0.08; '2.7': 0.13; '"copyright",': 0.16; '"credits"': 0.16; '"license"': 0.16; '2.7.2': 0.16; '[gcc': 0.16; 'conn': 0.16; 'exit()': 0.16; 'linux2': 0.16; 'mssql': 0.16; 'setuptools': 0.16; 'subject:result': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; '>>>': 0.18; 'subject:not': 0.19; 'seems': 0.20; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'feb': 0.22; '+0530': 0.23; 'cc:2**0': 0.26; 'module': 0.26; 'testing': 0.26; 'all,': 0.27; 'import': 0.27; 'print': 0.29; 'installed': 0.29; 'cc:addr:python.org': 0.29; 'skip:p 30': 0.29; 'components,': 0.30; 'queries.': 0.30; 'installation': 0.30; 'error': 0.30; 'thu,': 0.32; 'modules': 0.32; 'done': 0.34; 'things': 0.35; 'install': 0.35; 'post': 0.36; 'executing': 0.37; 'hat': 0.37; 'query': 0.37; 'but': 0.37; 'charset:us-ascii': 0.37; 'using': 0.37; 'received:128': 0.38; 'some': 0.38; 'data': 0.38; 'mailing': 0.39; 'change': 0.40; 'type': 0.61; 'more': 0.61; 'connect': 0.62; '95%': 0.84
Date Thu, 9 Feb 2012 07:31:56 -0500
From Rod Person <rodperson@rodperson.com>
To amarjeet yadav <amarjeet.java@gmail.com>
Subject Re: Can not get the result of query in pymssql module of python...
In-Reply-To <CAH8cRFCGOu0Fx6_Gn9uLCWr96v9ZPz1gKaAXADitU9thbr-GNA@mail.gmail.com>
References <CAH8cRFCGOu0Fx6_Gn9uLCWr96v9ZPz1gKaAXADitU9thbr-GNA@mail.gmail.com>
X-Mailer Claws Mail 3.7.10cvs7 (GTK+ 2.16.6; i586-pc-mingw32msvc)
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5584.1328791258.27778.python-list@python.org> (permalink)
Lines 53
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1328791258 news.xs4all.nl 6869 [2001:888:2000:d::a6]:38753
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20071

Show key headers only | 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