def save_to_sql(): df = ps.read_csv("./datas.csv",index_col=0) df.to_sql('movies_cop',con=engine,index=False,if_exists ='append')
时间: 2024-06-01 11:10:17 浏览: 143
(学习用)电影数据库“movies.csv”
5星 · 资源好评率100%
This function reads a CSV file named "datas.csv" and saves its contents to a SQL database table named "movies_cop". The function uses the pandas library to read the CSV file and convert it into a pandas DataFrame. It then uses the to_sql method to save the DataFrame to the SQL database using the provided SQLalchemy engine. The if_exists parameter is set to 'append', which means that if the table already exists, the data will be added to the existing data.
阅读全文