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
On Thu, Apr 14, 2011 at 7:06 AM, Johannes Radinger <[email protected]> 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
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
--
Martin
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users