<?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: Andriy Mykhaylyuk</title>
    <description>The latest articles on DEV Community by Andriy Mykhaylyuk (@1mehal).</description>
    <link>https://dev.to/1mehal</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%2F742183%2F46d11fd6-71d4-499b-a994-b9201f7492b9.jpeg</url>
      <title>DEV Community: Andriy Mykhaylyuk</title>
      <link>https://dev.to/1mehal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/1mehal"/>
    <language>en</language>
    <item>
      <title> Script to import IMDB database into PostgreSQL</title>
      <dc:creator>Andriy Mykhaylyuk</dc:creator>
      <pubDate>Mon, 22 Nov 2021 14:27:44 +0000</pubDate>
      <link>https://dev.to/1mehal/script-to-import-imdb-database-into-postgresql-2lj3</link>
      <guid>https://dev.to/1mehal/script-to-import-imdb-database-into-postgresql-2lj3</guid>
      <description>&lt;p&gt;It’s always nice to have some bigger database around to play with a new technologies. IMDB has a lot of data, but it’s not straightforward on how to import those into your PostgreSQL instance. I made a quick bash script to simplify the process.&lt;/p&gt;

&lt;h2&gt;
  
  
  Please make sure to have
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;csvkit&lt;/strong&gt; (python lib to work with CSV files) &lt;br&gt;
&lt;strong&gt;pv&lt;/strong&gt; (utility to monitor the progress of data through a pipe) &lt;br&gt;
installed. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To install &lt;strong&gt;csvkit&lt;/strong&gt; run: &lt;code&gt;sudo pip install csvkit&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;To install &lt;strong&gt;pv&lt;/strong&gt; run one of the following:

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;For Linux:&lt;/em&gt; &lt;code&gt;sudo apt-get install pv&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;For Mac Ports:&lt;/em&gt; &lt;code&gt;sudo port install pv&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;For Homebrew:&lt;/em&gt; &lt;code&gt;brew install pv&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To execute import script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bash &amp;lt;(wget -nv -O - https://gist.githubusercontent.com/1mehal/13c85e108cbc906f5ec34d28d75b1968/raw/imdb_import_in_postgresql.sh)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Script would attempt to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Download latest archive of IMDB data and put it to folder you specified or use existing data&lt;/li&gt;
&lt;li&gt;Create corresponding tables in PostgreSQL database (database should exists before running the script)&lt;/li&gt;
&lt;li&gt;Import data from tsv files into corresponding tables&lt;/li&gt;
&lt;li&gt;Set up primary keys and foreign keys and relationships between tables. Also script would setup search indexes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If something fails please follow up the script logic, and leave comments. bash script and corresponding sql scripts are located at &lt;a href="https://gist.github.com/1mehal/13c85e108cbc906f5ec34d28d75b1968"&gt;https://gist.github.com/1mehal/13c85e108cbc906f5ec34d28d75b1968&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s it.&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>tutorial</category>
      <category>showdev</category>
      <category>database</category>
    </item>
  </channel>
</rss>
