Questions tagged [fetchall]
165 questions
35
votes
6 answers
python postgres can I fetchall() 1 million rows?
I am using psycopg2 module in python to read from postgres database, I need to some operation on all rows in a column, that has more than 1 million rows.
I would like to know would cur.fetchall() fail or cause my server to go down? (since my RAM…

Medya Gh
- 4,563
- 5
- 23
- 35
32
votes
3 answers
Why is the same SQLite query being 30 times slower when fetching only twice as many results?
I have been working on speeding up a query I'm using for about a week now and asked several questions about it here ( How can I speed up fetching the results after running an sqlite query?, Is it normal that sqlite.fetchall() is so slow?, How to use…

Niek de Klein
- 8,524
- 20
- 72
- 143
24
votes
1 answer
About mysql cursor and iterator
Imagine I have a mysql cursor and data read. The amount of data might be very big that I want to deal with one line each time.
An easy and straight forward way might be like this:
while True:
row = cursor.fetchone()
if not row: break
…

taijirobot2
- 376
- 1
- 3
- 6
24
votes
3 answers
Fatal error: Call to undefined method mysqli_result::fetch_all()
I have problems with PHP in Ubuntu 10.04. When I try use mysqli_result::fetch_all this error appears:
Call to undefined method mysqli_result::fetch_all()
However, it works in Windows XP.
The Code:
$result = $this->dbh->query('SELECT [...] ');
return…

Stokres
- 685
- 2
- 7
- 12
15
votes
1 answer
PDO looping through and printing fetchAll
I'm having trouble getting my data from fetchAll to print selectively.
In normal mysql I do it this way:
$rs = mysql_query($sql);
while ($row = mysql_fetch_array($rs)){
$id = $row['id'];
$n = $row['n'];
$k = $row['k'];
}
In PDO, I'm…

Chris
- 8,736
- 18
- 49
- 56
8
votes
5 answers
php PDO fetchAll() - while not working, foreach works
I would like to know if i'm doing fine OR fetchAll() doesn't work with WHILE.
here is an exemple
$db=new PDO("mysql:host=" .$dbhost. "; dbname=" . $dbname, $dbuser, $dbpass);
$page=$db->prepare("SELECT * FROM page");
$page->execute();
foreach…

Mafitsi
- 97
- 1
- 1
- 3
7
votes
1 answer
PostgreSQL psycopg2 returns a tuple of strings instead of tuple of tuples?
I have a weird problem, and I'm not too sure how to fix it after searching Google/SO found nothing similar.
When I tried to grab query results from the cursor, it gives me a tuple of tuples, except the tuples are strings? Below is the code.
def…

user2524674
- 73
- 2
- 5
7
votes
2 answers
Php Prepared Statements Turn Emulation Off
Are there any side effects to turning off emulation when using prepared statements with pdo? I'm using a select * and limiting the results which needs to be handled as an int and not a string. I can do one of two things.
$conn->setAttribute(…

user2027231
- 169
- 2
- 19
6
votes
4 answers
[zend][db] fetchAll with multiple variables
I'm trying to use fetchAll on a query that has 2 variables. I can't figure out the syntax.
I can manage with only 1 variable:
$sql = "SELECT * FROM mytable WHERE field1 = ?";
$this->_db->fetchAll($sql,$value1); # that works
However I'm having some…

Max
- 12,794
- 30
- 90
- 142
5
votes
1 answer
Printing results from cursor.fetchall() without the trailing 'L'
I have a python code that accesses mysql through MySQLdb to run a select statement. I then use cursor.fetchall() to gather that output as an array, but the problem is it prints an L at the end of each output like so:
sql = "SELECT data1, data2 FROM…

curious_cosmo
- 1,184
- 1
- 18
- 36
5
votes
0 answers
Python is slow when iterating over a MySQL connector cursor
I have the following code that runs very slowly (6.5sec for iterating over 57,390 rows) :
import mysql.connector
cnx=mysql.connector.connect(host=***, ***)
cursorSQL = cnx.cursor()
for dt in date_vect:
cursorSQL.execute(query2, ((dt[0] +…

ylnor
- 4,531
- 2
- 22
- 39
5
votes
2 answers
Zend Framework fetchAll
Can i override fetchall method in a model? I need to check sth everytime fetchAll is called. The model extends Zend_db_table_abstract

Mote
- 11,197
- 1
- 18
- 10
4
votes
1 answer
python cx_Oracle cursor returns no rows for valid query
Beating my head against my desk on this one.
My cx_Oracle cursor is returning no rows for a valid query and I cannot figure out why.
The same connection returns expected results from other tables in same schema... for example if I simply change the…

bbaley
- 199
- 6
- 22
4
votes
1 answer
Loop through fetchall without knowing the fields php
I have a simple query which will fetch all from a users tables
$query = $this->pdo->prepare('SELECT * FROM `users`');
$query->execute();
return $query->fetchAll();
Then i would have a foreach loop like
$results = $User->getUser();
foreach($results…

user1217322
- 79
- 3
- 6
4
votes
1 answer
PDOStatement::fetchAll() is too slow
I'm running into a super slow PDOStatement::fetchAll() that is just driving me nuts.
My query is running in less than 0.1 seconds. Also in the MySQL terminal, I get my output on my screen in less than 0.1 seconds. But running fetchAll() on the…

ifokkema
- 49
- 4