gardsted a écrit : > Bruno Desthuilliers wrote: >> Andrey a écrit : >>> Hi >>> >>> just a quick question about using MySQL module... are there any api / >>> class available to give a higher level in working with Mysql in python? >>> such as >>> db.fetch_array(), >>> db.fetch_rows(), >>> db.query(), >>> for eachrow in db.fetch_array(): >>> xxxx >> (snip) > Maybe You should look into sqlalchemy. > I am also a newbie at that, but it allows you to do things like this > (untested): > sqltxt="""select * from mytable""" > result=mysession.execute(sqltxt) > for r in result.fetchmany(): > > which pretty good mimics the 'for eachrow in db.fetch_array():'
SQLAlchemy is quite a good package (and *way* higher level than anything in PHP), but you don't need it to do the above. Any db-api compliant package will do: sql = "SELECT * FROM yaddayadda" cursor.execute(sql) for row in cursor.fetchall(): # code here -- http://mail.python.org/mailman/listinfo/python-list