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
migrate_mysql_to_influxdb.py 文件源码
python
阅读 29
收藏 0
点赞 0
评论 0
评论列表
文章目录