migrate_mysql_to_influxdb.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:infra_helpers 作者: ayush-sharma 项目源码 文件源码
def get_data_from_mysql(host: str, username: str, password: str, db: str, sql: str):
    """ Run SQL query and get data from MySQL table. """

    db = MySQLdb.connect(host, username, password, db)

    cursor = db.cursor(MySQLdb.cursors.DictCursor)

    try:
        cursor.execute(sql)
        data = cursor.fetchall()
    except Exception as e:
        print("MySQL error %s: %s" % (e.args[0], e.args[1]))
        data = None

    db.close()

    return data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号