-------- Original-Nachricht --------
> Datum: Thu, 14 Apr 2011 10:34:25 -0400
> Von: Martin Gadbois <mgadb...@gmail.com>
> An: General Discussion of SQLite Database <sqlite-users@sqlite.org>
> Betreff: Re: [sqlite] Python loop over Sqlite database

> Try:
> 
> import sqlite3
> conn = sqlite3.connect("database")
> c = conn.cursor()
> c.execute('SELECT * FROM table ORDER BY X')
> 
> for row in c:
>     print row[2] # Where 2 is the X column

Thank you very much, I just found that out myself :)


> 
> 
> On Thu, Apr 14, 2011 at 7:06 AM, Johannes Radinger <jradin...@gmx.at>
> wrote:
> 
> > Hello,
> >
> > I have a table in a sqlite database which looks like:
> >
> > RowID : Dist  : X  :  Y
> > 1        : 1.24 : 15 : 15
> > 2        : 0.66 : 13 : 17
> > 3        : 0.82 :  8 : 12
> > 4        : 2.14 : 17 : 19
> > 5        : 1.83 : 15 : 13
> >
> > I want to loop over the single entries of the database-table using
> Python:
> >
> > 1) a loop over the rowid from the beginning to the end (1 to 5) of the
> > table and I want to get the values for X. The result should give: 15,
> 13, 8,
> > 17, 15
> >
> > 2) I also want a loop over the list and want to get again X but in this
> > case I want to get it in an ordered way, I want to get i ordered from
> the
> > smalles Dist-value to the greatest Dist-value. So the result of the loop
> > should be: 13, 8, 15, 15, 17
> >
> > Do you know what I mean? How can I do that? How to loop over the entries
> of
> > a sqlite database using Python?
> >
> > /Johannes
> >
> > --
> > GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit
> > gratis Handy-Flat! http://portal.gmx.net/de/go/dsl
> > _______________________________________________
> > sqlite-users mailing list
> > sqlite-users@sqlite.org
> > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> >
> 
> 
> 
> -- 
> Martin
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

-- 
NEU: FreePhone - kostenlos mobil telefonieren und surfen!                       
Jetzt informieren: http://www.gmx.net/de/go/freephone
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to