python 操作mysql

来源:互联网 发布:spss如何转换数据 编辑:程序博客网 时间:2024/06/07 00:16
def query():    conn= MySQLdb.connect(        host='localhost',        port = 3306,        user='root',        passwd='1234567',        db ='tlcb',        )    cur = conn.cursor()    a=cur.execute("select title,body, DATE_FORMAT(timestamp,'%Y~%m~%d %k.%i.%s') A from blog_blogpost")    info = cur.fetchmany(a)    print info    print type(info)    return info    cur.close()    conn.close()