在Datagrip中导入CSV

时间:2020-01-27 12:49:28

标签: mysql json csv datagrip

我在导入具有超过4万条记录的CSV文件时遇到了一些麻烦。我要导入的表具有多个关系,并且当该表尝试导入记录时,在关系表中存在没有这些记录的记录,因此创建记录失败(至少是我的猜测)。请注意,这种关系是0到许多。

我的CSV表结构如下:

False,"{'id': 10194, 'name': 'Toy Story Collection', 'poster_path': '/7G9915LfUQ2lVfwMEEhDsn3kT4B.jpg', 'backdrop_path': '/9FBwqcd9IRruEDUrTdcaafOMKUq.jpg'}",30000000,"[{'id': 16, 'name': 'Animation'}, {'id': 35, 'name': 'Comedy'}, {'id': 10751, 'name': 'Family'}]",http://toystory.disney.com/toy-story,862,tt0114709,en,Toy Story,"Led by Woody, Andy's toys live happily in his room until Andy's birthday brings Buzz Lightyear onto the scene. Afraid of losing his place in Andy's heart, Woody plots against Buzz. But when circumstances separate Buzz and Woody from their owner, the duo eventually learns to put aside their differences.",21.946943,/rhIRbceoE9lR4veEXuwCC2wARtG.jpg,"[{'name': 'Pixar Animation Studios', 'id': 3}]","[{'iso_3166_1': 'US', 'name': 'United States of America'}]",1995-10-30,373554033,81.0,"[{'iso_639_1': 'en', 'name': 'English'}]",Released,,Toy Story,False,7.7,5415 

一条记录如下:

2:8: conversion failed: "{'id': 10194, 'name': 'Toy Story Collection', 'poster_path': '/7G9915LfUQ2lVfwMEEhDsn3kT4B.jpg', 'backdrop_path': '/9FBwqcd9IRruEDUrTdcaafOMKUq.jpg'}" to int

所以我确实重新创建了关系表“ belongs_to_collection”,“类型”,“ production_companies”,“ production_countries”和“ spoken_languages”

当我使用Datagrip向导时,我会创建外键和内容,但是在运行时会出现以下错误:

SELECT AIR_ARB, COUNT(*) FROM
(
SELECT AIR_ARB FROM AIR_INFO  WHERE  V_VX IN (910208,910209,9......) AND V_Y IN
(826369,826370,8.....)
UNION ALL
SELECT AIR_MAT FROM AIR_INFO WHERE  V_VX IN (910208,910209,9......) AND V_Y IN 
(826369,826370,8.....)

) t
GROUP BY AIR_ARB
ORDER BY COUNT (*) desc

0 个答案:

没有答案