Is there something easier than ORM?
"Martin v. Löwis"
martin at v.loewis.de
Tue Feb 17 13:54:11 EST 2009
> So is there some libraries like that?
I always use a DB-API implementation for the database I use,
i.e. psycopg/psycopg2.
Named tuples are really easy to provide:
class NamedTuple:
def __init__(self, names, values):
for name, value in izip(names, values):
setattr(self, name, value)
person_rows = "first last age".split()
def get_person(conn, id):
conn.execute("select first, last, age from person where id=%d"
% (id,))
return NamedTuple(person_rows, conn.fetchone())
Regards,
Martin
More information about the Python-list
mailing list