简体   繁体   中英

pymysql and writing a pandas dataframe back to MySQL

I am in Python and have a Pandas dataframe called Office_RX.

I am connected to mysql via pymysql.

conn = pymysql.connect(host='127....', port=3306, user='root', passwd='', db='ABCD')
c = conn.cursor()

I want to write the Office_RX dataframe back into the MYSQL db I am connected to.

I am using this code:

sql.write_frame(Office_RX, conn=conn, name='Office_RX', if_exists='replace', flavor='mysql')

But I get the error: TypeError: write_frame() takes at least 3 arguments (4 given)

Can tell what I am doing wrong. Suggestions?

The argument in write_frame is con rather than conn:

sql.write_frame(Office_RX, con=conn, name='Office_RX', if_exists='replace', flavor='mysql')

This function accepts **kwargs , hence the vaguely cryptic error message.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM