473,385 Members | 1,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

mysqldb: Rows READ or Processed

mcl
I have looked through Python Database API Specification v2.0, but can
not find any reference to the number of records processed in a select
query.

I know I can get the number of records returned with cursor.rowcount,
but I want to know the number of records processed.

I suppose the info is in one of the internal tables, but I can not
find any info on that, because phpMyAdmin shows the number of rows in
a table.

I suppose I could use count(*), but would that process all the
records, which would seem a bit silly.

What is the best method ?

Richard

Feb 6 '08 #1
4 1715
On Wed, 2008-02-06 at 18:53 -0500, Steve Holden wrote:
If you mean the number of (say) rows updated by a SQL UPDATE statement,
the DB API does not provide any way to access that information
It doesn't? Isn't that what cursor.rowcount does?

--
Carsten Haese
http://informixdb.sourceforge.net
Feb 7 '08 #2
On Wed, 2008-02-06 at 14:51 -0800, mcl wrote:
I have looked through Python Database API Specification v2.0, but can
not find any reference to the number of records processed in a select
query.

I know I can get the number of records returned with cursor.rowcount,
but I want to know the number of records processed.

I suppose the info is in one of the internal tables, but I can not
find any info on that, because phpMyAdmin shows the number of rows in
a table.

I suppose I could use count(*), but would that process all the
records, which would seem a bit silly.

What is the best method ?
Please define what you mean by "processed". If you simply need to know
how many rows are in a table, "select count(*) from that_table" is the
obvious solution. If the database engine is sufficiently intelligent, it
won't have to read the data in every single row to count the rows.

If that's not what you're looking for, please feel free to be more
specific about what you need to achieve.

--
Carsten Haese
http://informixdb.sourceforge.net
Feb 7 '08 #3
mcl
On Feb 7, 12:19 am, Carsten Haese <cars...@uniqsys.comwrote:
On Wed, 2008-02-06 at 14:51 -0800, mcl wrote:
I have looked through Python Database API Specification v2.0, but can
not find any reference to the number of records processed in a select
query.
I know I can get the number of records returned with cursor.rowcount,
but I want to know the number of records processed.
I suppose the info is in one of the internal tables, but I can not
find any info on that, because phpMyAdmin shows the number of rows in
a table.
I suppose I could use count(*), but would that process all the
records, which would seem a bit silly.
What is the best method ?

Please define what you mean by "processed". If you simply need to know
how many rows are in a table, "select count(*) from that_table" is the
obvious solution. If the database engine is sufficiently intelligent, it
won't have to read the data in every single row to count the rows.

If that's not what you're looking for, please feel free to be more
specific about what you need to achieve.

--
Carsten Haesehttp://informixdb.sourceforge.net
Thanks for all the helpful replies.

If you think Count(*) is intelligent, then that is the easy answer. I
will attempt to do some timings.

I did mean number of rows in a table - by processed.
Feb 7 '08 #4
On Wed, 2008-02-06 at 21:35 -0500, Steve Holden wrote:
Carsten Haese wrote:
On Wed, 2008-02-06 at 18:53 -0500, Steve Holden wrote:
If you mean the number of (say) rows updated by a SQL UPDATE statement,
the DB API does not provide any way to access that information
It doesn't? Isn't that what cursor.rowcount does?
When it works, yes. Perhaps I should have said that the method provided
by the DB API isn't reliably implemented (for example, on SQL Server
2000 via mx.ODBC it would use a forward cursor which had no predictive
ability about its contents).
Yes, and the same will happen with Informix on a SELECT statement, for
pretty much the same reason. However, you have claimed that the number
of rows updated by an UPDATE statement is not provided, and I have yet
to see a DB-API implementation that doesn't set cursor.rowcount
correctly after executing an UPDATE statement. (The spec doesn't require
that the rowcount be set reliably after an update, but any sane database
engine ought be able to tell you how many rows it touched in an update!)

Anyway, as you said, the point is moot, I just wanted to make sure we're
all on the same page.

--
Carsten Haese
http://informixdb.sourceforge.net
Feb 7 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Chris Stromberger | last post by:
When issuing updates in mysql (in the console window), mysql will tell you if any rows matched and how many rows were updated (see below). I know how to get number of rows udpated using MySQLdb,...
1
by: Sheila King | last post by:
I have searched for an answer to this question on the comp.lang.python archives at Google Groups, and also looked through the (sparse) MySQLdb documentation, and cannot confirm for a FACT what I...
1
by: Derek Fountain | last post by:
I was trying to use MySQLdb to connect to a database. All is OK, except I can't figure out how to get the details of an error. Suppose I try to connect to a non existant server, or with the wrong...
1
by: JZ | last post by:
I cannot execute insert data into TEXT field if that data is bigger than 64KB. :( >>> cursor.execute("INSERT INTO table (field) VALUES(%s) WHERE id=1", myValue) Traceback (most recent call...
2
by: Tim Williams | last post by:
I'm trying to write a simple python program to access a MySQL database. I'm having a problem with using MySQLdb to get the results of a SQL command in a cursor. Sometimes the cursor.execute works,...
21
by: John Fabiani | last post by:
Hi, I'm a newbie and I'm attempting to learn howto create a select statement. When I use >>> string1='18 Tadlock Place' >>> cursor.execute("SELECT * FROM mytest where address = %s",string1) All...
1
by: Yi Xing | last post by:
Hi, I met the following error when I tried to install MySQLdb. I had no problem installing numarray, Numeric, Rpy, etc. Does anyone know what's the problem? Thanks! running install running...
2
by: Nikhil | last post by:
I am using the MySQLdb python module. I have a table named 'testing' with few columns, under the 'test' database, what is hosted on a remote mysql server. I want to run the following query to...
0
by: Edwin.Madari | last post by:
replace the name of table before calling *.execute. s.dbptr.execute(str % (e)) good luck. Edwin -----Original Message----- From: python-list-bounces+edwin.madari=verizonwireless.com@python.org...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.