操作mysql脚本

 

 

 

def mysql_conn():
    while 1:
        try:
            conn, mysql = mysql_conn_e()
            return conn, mysql
        except Exception as e:
            print("save 链接数据库 出错")
            time.sleep(1)


def mysql_conn_e():
    conn = pymysql.connect(host=DBHOST, port=DBPORT, user=DBUSER,
                           password=DBPWD, database=DBNAME,
                           charset=DBCHAR)

    mysql = conn.cursor(cursor=pymysql.cursors.DictCursor)

    return conn, mysql






 

posted @ 2022-04-11 14:01  AngDH  阅读(19)  评论(0编辑  收藏  举报