How to set specific column when saving to sql?

Viewed 43

I am currently using the following two-step process to save a dataframe to mysql:

actions_df.to_sql('mytable', con=self.avails_conn, if_exists='replace', index='id', 
        dtype={col_name: VARCHAR(255) for col_name, type in df.dtypes.items() if (type=='O') and (col_name != 'path')}
)
self.avails_conn.execute("ALTER TABLE mytable CHANGE path path VARCHAR(500) CHARACTER SET ascii")

How would I specify the exact column information, VARCHAR(500) CHARACTER SET ascii in the 'dtype' section?

0 Answers
Related