python odo sql AssertionError: datashape must be Record type, got 0 * {…}

前端 未结 3 2153
迷失自我
迷失自我 2021-01-03 04:19

I\'m trying to import a CSV into MySQL using odo but am getting a datashape error.

My understanding is that datashape takes the format:

var * {
    c         


        
相关标签:
3条回答
  • 2021-01-03 04:52

    Odo seems to be buggy and discontinued. As an alternative you can use d6tstack which has fast pandas to SQL functionality because it uses native DB import commands. It supports Postgres, MYSQL and MS SQL,

    cfg_uri_mysql = 'mysql+mysqlconnector://testusr:testpwd@localhost/testdb'
    d6tstack.combine_csv.CombinerCSV(glob.glob('*.csv'), 
        apply_after_read=apply_fun).to_mysql_combine(uri_psql, 'table')
    

    Also particularly useful for importing multiple CSV with data schema changes and/or preprocess with pandas before writing to db, see further down in examples notebook

    0 讨论(0)
  • 2021-01-03 04:53

    Try replacing

    odo('test.csv', mysql_database_uri) 
    

    with

    odo(pandas.read_csv('test.csv') , mysql_database_uri)
    
    0 讨论(0)
  • 2021-01-03 05:03

    I had this error, needed to specify table

    # error
    odo('data.csv', 'postgresql://usr:pwd@ip/db')
    
    # works
    odo('data.csv', 'postgresql://usr:pwd@ip/db::table')
    
    0 讨论(0)
提交回复
热议问题