473,387 Members | 1,834 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,387 software developers and data experts.

Re: Problem with sqlite3 cursor and imbricated for loop

Gerhard Häring wrote:
Steve Holden wrote:
[...]
>>>
It's also why SQLite's not a real RDBMS. Fortunately this doesn't stop
it being very useful.

What does pysqlite extending the DB-API have to do with *SQLite* not
being a "real" RDBMS?
Nothing at all. I was just being pissy. Sorry about that.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Nov 13 '08 #1
1 3210
c.execute("select * from stocks")
for s in list(c):
print s[0]
c.execute("select * from stocks where price<20")
for sp in c:
print ' '+sp[0]
c.close()

The simple addition of list() should do away with the dependency on
mysql's implementation, since it forces the instant fetch of all data.
Whether that is better than to use a 2nd cursor is probably a matter
of taste.

Using "*" in selects is always bad, though. ;)
Nov 19 '08 #2

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

Similar topics

2
by: John Machin | last post by:
Apologies in advance if this is a bit bloggy, but I'd like to get comments on whether I've lost the plot (or, more likely, failed to acquire it) before I start reporting bugs etc. From "What's...
38
by: John Salerno | last post by:
Here's my script: import sqlite3 con = sqlite3.connect('labdb') cur = con.cursor() cur.executescript(''' DROP TABLE IF EXISTS Researchers; CREATE TABLE Researchers ( researcherID...
16
by: BartlebyScrivener | last post by:
I am a mere hobbyist. Spent several hours trying to make a class, because I think this is an occasion where I need one. But I can't make it work. This code "works" (only because of the global c,...
0
debasisdas
by: debasisdas | last post by:
SAMPLE CODE USING RECORD =========================== declare cursor c1 is select * from dept; type drec is record (a dept.deptno%type, b dept.dname%type, c dept.loc%type); type ttype is...
13
by: mark carter | last post by:
I hesitate to ask, but ... I'm using Ubuntu Feisty: * Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) on linux2 * SQLite version 3.3.13 Suppose I run the following program: import sqlite3
33
by: Stef Mientki | last post by:
hello, I discovered that boolean evaluation in Python is done "fast" (as soon as the condition is ok, the rest of the expression is ignored). Is this standard behavior or is there a compiler...
4
by: coldpizza | last post by:
Hi, I want to run a database query and then display the first 10 records on a web page. Then I want to be able to click the 'Next' link on the page to show the next 10 records, and so on. My...
0
by: Ben Lee | last post by:
hi folks -- a quick python and sqlite3 performance question. i find that inserting a million rows of in-memory data into an in-memory database via a single executemany() is about 30% slower...
0
by: Charles V. | last post by:
Hi, I hope this is not already known. But Google wasn't any help. So here begins a script to explain my problem. ------------------------- import sqlite3 conn = sqlite3.connect(':memory:')...
0
by: Steve Holden | last post by:
Charles V. wrote: If you are trying to tell us that your code "works" under MySQL but not under SQLite I want to see the proof. Otherwise I don;t believe you. regards Steve PS: What does...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.