#!/usr/bin/python
# -*- coding: UTF-8 -*-
import numpy as np
import mysql.connector
cnx = mysql.connector.connect(user='xxxx', password='xxxxx',
host='xxxx',
database='xxxx')
df=pd.read_sql_query("SELECT * FROM table xxx",cnx)
print(df)
使用read_sql_query函数即可,'xxxx'表示实际值,安全起见隐去
本文介绍如何使用Python的pandas库结合mysql.connector模块从MySQL数据库中读取数据,并展示了一个具体的示例代码。
605

被折叠的 条评论
为什么被折叠?



