1

I created mysql DB, then i changed some variables types to "longtext", then i created dataframe in pandas, and pushed that df to DB

df.to_sql("my_table_name", conn, index=False, if_exists = 'replace')

this command insert data to DB but the variables types become default text.

Amir saleem
  • 1,404
  • 1
  • 8
  • 11
  • there is an argument for `dtypes` in `to_sql` you can pass in a dictionary of your column names and types. what engine are you using `sqlalchemy`? – Umar.H May 15 '20 at 16:38

0 Answers0