How to Import Multiple csv files into a MySQL Database

后端 未结 9 1627
深忆病人
深忆病人 2020-11-30 06:14

Is there a way to import multiple csv files at the same time into a MySQL database? Some sort of batch import?

I\'m on Mac OSX running a MAMP server.

I have

9条回答
  •  星月不相逢
    2020-11-30 06:49

    In python you can use d6tstack which makes this simple

    import d6tstack
    import glob
    
    c = d6tstack.combine_csv.CombinerCSV(glob.glob('*.csv'))
    c.to_mysql_combine('mysql+mysqlconnector://usr:pwd@localhost/db', 'tablename')
    

    It also deals with data schema changes, creates table and allows you to preprocess data.

提交回复
热议问题