PyMySQL Error: 'str' object has no attribute 'to_sql'

时间:2017-08-30 20:44:24

标签: python mysql pymysql

I'm new to coding and this my first project. So far I've pieced together what I have through Googling, Tutorials and Stack.

I'm trying to add data from a pandas df of scraped RSS feeds to a remote sql database. I've been using a combo of this post and this post to fix my error but the answers don't seem to work with my problem.

Does anyone have a potential solution to the error:


AttributeError Traceback (most recent call last) in () 19 cursor.execute(sql) 20 ---> 21 sql.to_sql(df, con=conn, name='rsstracker', if_exists='append', flavor='mysql') 22 23 # disconnect from server

AttributeError: 'str' object has no attribute 'to_sql'

^([\r\n]*)(@.*?{[\r\n]*)?((?!\[data-module=(['"])\d+\4\])[^@\r\n{}])+({[\s\S]*?})([\r\n]*})?$

1 个答案:

答案 0 :(得分:1)

The line should be :

$dateRange

But you may need to use SQLAlchemy to make this export possible (doc)


You can try to use SQLAlchemy with pymysql like in the following lines :

$dateRange