<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Howard Chu</title>
    <description>The latest articles on DEV Community by Howard Chu (@howardchu).</description>
    <link>https://dev.to/howardchu</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1024402%2F8884f8d0-777f-4434-a34f-e0b796ee8cc0.jpeg</url>
      <title>DEV Community: Howard Chu</title>
      <link>https://dev.to/howardchu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/howardchu"/>
    <language>en</language>
    <item>
      <title>Best way to import csv file into Mysql</title>
      <dc:creator>Howard Chu</dc:creator>
      <pubDate>Mon, 20 Feb 2023 15:57:15 +0000</pubDate>
      <link>https://dev.to/howardchu/best-way-to-import-csv-file-into-mysql-30bo</link>
      <guid>https://dev.to/howardchu/best-way-to-import-csv-file-into-mysql-30bo</guid>
      <description>&lt;p&gt;Having tried mysqlimport command, navicat import wizard, mysql workbench, the best way to import my kinda large csv into mysql is using &lt;code&gt;LOAD DATA INFILE&lt;/code&gt; command (in mysql cli).&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Saw from the thumbnail, using an import wizard to import wukong dataset's csv file just doesn't work. &lt;/li&gt;
&lt;li&gt;Mysqlimport(high upvotes from Stackoverflow) also doesn't work, it cuts the data in the csv file.&lt;/li&gt;
&lt;li&gt;Using mysql workbench to import the csv file just leads to straight up crashing.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Finally, the way it worked, moreover, the way it worked properly and user-friendly, is to use the &lt;code&gt;LOAD DATA INFILE&lt;/code&gt; supported in mysql cli as a part of SQL language.&lt;/p&gt;

&lt;p&gt;Here's the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LOAD DATA INFILE '/Users/**/Desktop/Cabin/yagoo/resources/wukong_test.csv' 
INTO TABLE wukong_data
FIELDS TERMINATED BY ',' 
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS
(dir, text, token, url, alt_id);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will have to create the table first. Using &lt;code&gt;head -n 1 wukong_test.csv&lt;/code&gt; to see the column names to work with.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;output:
~/Desktop/Cabin/yagoo/resources$ head -n *.csv 
dir,text,token,url,alt_id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Most importantly, which is not a feature in any of the failing methods above, is that using &lt;code&gt;LOAD DATA INFILE&lt;/code&gt; can tell you exactly why the import has failed. For me, it's mostly because in some of the column, the string is to long, I didn't set VARCHAR for enough capacity. If so, it'll output a message, telling which row the error took place, and why.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mysql&amp;gt; LOAD DATA INFILE '/Users/**/Desktop/Cabin/yagoo/resources/wukong_test.csv' 
    -&amp;gt; INTO TABLE wukong_data_test
    -&amp;gt; FIELDS TERMINATED BY ',' 
    -&amp;gt; ENCLOSED BY '"'
    -&amp;gt; LINES TERMINATED BY '\n'
    -&amp;gt; IGNORE 1 ROWS
    -&amp;gt; (dir, text, token, url, alt_id);;

ERROR 1406 (22001): Data too long for column 'url' at row 32357
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So please stick to sql more!&lt;/p&gt;

&lt;p&gt;ps: You might need to tweak a little to make &lt;code&gt;LOAD DATA INFILE&lt;/code&gt; work on your device.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Hey Hey my first post</title>
      <dc:creator>Howard Chu</dc:creator>
      <pubDate>Fri, 10 Feb 2023 16:08:13 +0000</pubDate>
      <link>https://dev.to/howardchu/hey-hey-my-first-post-44m6</link>
      <guid>https://dev.to/howardchu/hey-hey-my-first-post-44m6</guid>
      <description>&lt;p&gt;brew services start redis&lt;/p&gt;

&lt;p&gt;brew services info redis&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;redis &lt;span class="o"&gt;(&lt;/span&gt;homebrew.mxcl.redis&lt;span class="o"&gt;)&lt;/span&gt;
Running: ✔
Loaded: ✔
User: miranda
PID: 67975
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;brew services stop redis&lt;/p&gt;

&lt;h2&gt;
  
  
  Connect to Redis
&lt;/h2&gt;

&lt;p&gt;redis-cli&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
