[Tutor] sqlite3 Question

Khalid Al-Ghamdi emailkgnow at gmail.com
Wed Jun 6 21:29:27 CEST 2012


Hi All,

hi Joel,

Regarding sqlite3 practice code below:


   1. import sqlite3
   2. conn=sqlite3.connect("mydb2.db")
   3. c=conn.cursor()
   4. c.execute('create table family (Id integer primary key, name text,
   age integer)')
   5. c.execute("insert into family values (1,'elham',32)")
   6. c.execute('select * from family')
   7. conn.commit()
   8. for i in c:
   9.     print(i)


Why is it that if I call the for statement in the shell it doesn't print
the information more than once? I've found this to be true in other
situations where cursor carries the data only once. So, how can i
manipulate/use the data if I can only access it once? I have tried applying
useing x=list(c), but it doesn't seem to work!

Any guidance?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120606/180ca991/attachment.html>


More information about the Tutor mailing list