import sysimport MySQLdbimport MySQLdb.cursorsconn = MySQLdb.Connect( host='localhost', user='vroom', passwd='vroom', db='vroom',compress=1, cursorclass=MySQLdb.cursors.DictCursor)cursor = conn.cursor()cursor.execute("SELECT * FROM posts")rows = cursor.fetchall()cursor.close()conn.close()for row in rows: print row['title'], row['create_date']
No comments:
Post a Comment