问题描述
我正在尝试使用odo将CSV导入MySQL,但出现数据形状错误.
I'm trying to import a CSV into MySQL using odo but am getting a datashape error.
我的理解是datashape采用以下格式:
My understanding is that datashape takes the format:
var * {
column: type
...
}
其中var表示行数可变.我收到以下错误:
where var means a variable number of rows. I'm getting the following error:
AssertionError: datashape must be Record type, got 0 * {
tod: ?string,
interval: ?string,
iops: float64,
mb_per_sec: float64
}
我不确定0的行来自何处.我尝试使用dshape()
显式设置datashape,但继续出现相同的错误.
I'm not sure where that 0 number of rows is coming from. I've tried explicitly setting the datashape using dshape()
, but continue to get the same error.
下面是重新生成错误的代码的精简版本:
Here's a stripped down version of the code that recreates the error:
from odo import odo
odo('test.csv', mysql_database_uri)
我正在使用Conda运行Ubuntu 16.04和Python 3.6.1.
I'm running Ubuntu 16.04 and Python 3.6.1 using Conda.
感谢您的任何输入.
推荐答案
我遇到了此错误,需要指定表
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')
这篇关于蟒蛇odo sql AssertionError:datashape必须是记录类型,得到0 * {...}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!