Python Database Objects (PDO) 1.2.0 Released

Serge Orlov sombDELETE at pobox.ru
Wed Nov 19 01:42:54 CET 2003


[Jon Franz]
> PDO:
> import pdo
>
> mycon = pdo.connect("module=MySQLdb;user=test;passwd=foobar;db=sample")
> results = mycon.open("SELECT * FROM Customers")
> while results.next():
>     print "Name: " + results['Name'].value
>     print "Address: " + results['Address'].value
>     print "Size of 'Name' column in the db: " + str(results['Name'].length)

Why don't you use iterators for that?
for result in mycon.open("SELECT * FROM Customers"):
    print ...

Besides you're even "abusing" .next() method which you use to provide
iterations in a different way. Confusing...

--  Serge Orlov.






More information about the Python-list mailing list