0
votes

I've looked in many places and a lot of answers this but i really didn't found.

The problem is: I have a CSV file that i'm filling a pandas dataframe, and then i want to insert those dataframe into a MySQL database.

  engine = create_engine("mysql+mysqldb://USER:"+'PSWRD'+"@HOST:3306/schema", echo=False)
  with engine.connect() as conn, conn.begin():
       df.to_sql(name='tbl_TestPython',con=conn, if_exists='append', index=False)

When i run this i get no error, but in my database nothing changes ( nothing inserted).I tried to change "if_exists" to 'replace' but didn't work, also tried to remove "With engine...." and let just the line "df.to_sql..." but nothing too, any mistakes or inserted data

Could anyone help please?

1
check in information_schema.tables whether your table has been created in another DB... - MaxU
I saw that, the table is in the same DB ;/ - Clayton Tosatti
so the table does exist? Try to use another table name like 'tbl_TestPython2' and check whether it'll be created in MySQL DB - MaxU
Yeah, i tried that and i got the problem. I don't know why my proxy was blocking my connection to the database and it wasn't appearing in python ( i got it seeing my network traffic). So it's all solved thanks man!! - Clayton Tosatti

1 Answers

0
votes

Guys after trying for some time i finally got what was happening with the help of MaxU.

The problem was with my network, the proxy was blocking the connection from MysqlDB when i tried to insert something. I changed this and now it's working fine