首页 > 代码库 > python mysql模块

python mysql模块

#!/usr/bin/python

import MySQLdb


def new_mail_mysql(ak):

    print ak

    conn=MySQLdb.connect(host=‘m3306.sae.sina.com.cn‘,user=‘sae_ol‘,passwd=‘7b149edb22ae7526‘,db=‘sae‘,port=3306)

    cur=conn.cursor()

    sql="select name from app where accesskey=‘%s‘"%ak

    cur.execute(sql)

    app_name=cur.fetchall()

    return app_name

    cur.close()

    conn.close()


if __name__ == ‘__main__‘:

    ak=new_mail_mysql(‘4yywo5lm02‘)

    print ak


本文出自 “expect批量同步数据” 博客,请务必保留此出处http://4249964.blog.51cto.com/4239964/1433462