params : list, tuple or dict, optional, default: None
List of parameters to pass to execute method. The syntax used to pass parameters is database driver dependent. Check your database driver documentation for which of the five syntax styles, described in PEP 249’s paramstyle, is supported. Eg. for psycopg2, uses %(name)s so use params={‘name’ : ‘value’}
parse_dates : list or dict, default: None
List of column names to parse as dates.
要解析为日期的列名列表。
Dict of {column_name: format string} where format string is strftime compatible in case of parsing string times, or is one of (D, s, ns, ms, us) in case of parsing integer timestamps.
Dict of {column_name: arg dict}, where the arg dict corresponds to the keyword arguments of pandas.to_datetime() Especially useful with databases without native Datetime support, such as SQLite.
index_col : string or list of strings, optional, default: None
Column(s) to set as index(MultiIndex).
要设置为索引的列(MultiIndex)。
coerce_float : boolean, default True
Attempts to convert values of non-string, non-numeric objects (like decimal.Decimal) to floating point. Can result in loss of Precision.
尝试将非字符串,非数字对象(如decimal.Decimal)的值转换为浮点值。可能导致精度损失。
parse_dates : list or dict, default: None
List of column names to parse as dates.
要解析为日期的列名列表。
Dict of {column_name: format string} where format string is strftime compatible in case of parsing string times or is one of (D, s, ns, ms, us) in case of parsing integer timestamps.
Dict of {column_name: arg dict}, where the arg dict corresponds to the keyword arguments of pandas.to_datetime() Especially useful with databases without native Datetime support, such as SQLite.
If specified, returns an iterator where chunksize is the number of rows to include in each chunk.
如果指定,则返回一个迭代器,其中chunksize是要包含在每个块中的行数。
Returns:
DataFrame
使用案例
import pandas as pd
import pymysql
from sqlalchemy import create_engine
con = create_engine('mysql+pymysql://user_name:password@127.0.0.1:3306/database_name')
data = pd.read_sql_table("table_name", con)
data.to_csv("table_name.csv")