1

使用以下命令安装 csvkit 后

$ sudo -HE pip install --upgrade -e git+git://github.com/wireservice/csvkit.git@master#egg=csvkit

并尝试.csv按如下方式导入 a:

csvsql --db mysql://root:root@127.0.0.1:3306/jira_test --insert --table bugs_temp --no-constraints --overwrite --create-if-not-exists --no-inference --blanks bugs_temp.csv

我收到以下错误

/usr/local/lib/python2.7/dist-packages/agate/utils.py:292: DuplicateColumnWarning: Column name "0" already exists in Table. Column will be renamed to "0_2".
/usr/local/lib/python2.7/dist-packages/agate/utils.py:292: DuplicateColumnWarning: Column name "0" already exists in Table. Column will be renamed to "0_3".
/usr/local/lib/python2.7/dist-packages/agate/utils.py:292: DuplicateColumnWarning: Column name "0" already exists in Table. Column will be renamed to "0_4".
/usr/local/lib/python2.7/dist-packages/agate/utils.py:292: DuplicateColumnWarning: Column name "0" already exists in Table. Column will be renamed to "0_5".
/usr/local/lib/python2.7/dist-packages/agate/utils.py:292: DuplicateColumnWarning: Column name "0" already exists in Table. Column will be renamed to "0_6".
/usr/local/lib/python2.7/dist-packages/agate/utils.py:292: DuplicateColumnWarning: Column name "0" already exists in Table. Column will be renamed to "0_7".
/usr/local/lib/python2.7/dist-packages/agate/utils.py:292: DuplicateColumnWarning: Column name "0" already exists in Table. Column will be renamed to "0_8".
/usr/local/lib/python2.7/dist-packages/agate/utils.py:292: DuplicateColumnWarning: Column name "0" already exists in Table. Column will be renamed to "0_9".
(in table 'bugs_temp', column 'ESS-3146'): VARCHAR requires a length on dialect mysql
4

1 回答 1

0

(这个答案可能有点不完整。我没有经验csvsql,所以我把它变成了一个维基。)

csvkit 取决于agate-sql取决于sqlalchemy。_ _

sqlalchemy包含这行代码

    "VARCHAR requires a length on dialect %s" % self.dialect.name

引用这个答案,似乎“<em>您需要为所有字符串指定长度” 。

这意味着您不能使用该--no-constraints选项:

  --no-constraints      Generate a schema without length limits or null
                        checks. Useful when sampling big tables.

请参阅https://csvkit.readthedocs.io/en/latest/scripts/csvsql.html

于 2019-03-21T09:08:56.483 回答