import _mysql as mysql
db=mysql.connect('localhost','username','password','database')
db.query("""select * from news""")
result = db.store_result()
print result.num_rows()#two records
#how to loop? without cursor
print result.fetch_row()
import _mysql as mysql db=mysql.connect(‘localhost’,’username’,’password’,’database’) db.query(select * from news) result = db.store_result() print result.num_rows()#two
Share
You can try this:
I second @Ignacio‘s note of caution against using
_mysql. Switch toimport MySQLdb.