<?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: John Akindipe</title>
    <description>The latest articles on DEV Community by John Akindipe (@johnakindipe).</description>
    <link>https://dev.to/johnakindipe</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%2F1381681%2F105a2f29-ff66-4fde-8714-65b2ba5996a0.png</url>
      <title>DEV Community: John Akindipe</title>
      <link>https://dev.to/johnakindipe</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/johnakindipe"/>
    <language>en</language>
    <item>
      <title>Inheritance in OOP</title>
      <dc:creator>John Akindipe</dc:creator>
      <pubDate>Thu, 20 Jun 2024 05:08:38 +0000</pubDate>
      <link>https://dev.to/johnakindipe/inheritance-in-oop-2190</link>
      <guid>https://dev.to/johnakindipe/inheritance-in-oop-2190</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for &lt;a href="https://dev.to/challenges/cs"&gt;DEV Computer Science Challenge v24.06.12: One Byte Explainer&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Explainer
&lt;/h2&gt;

&lt;p&gt;Inheritance is an important paradigm in OOP. It refers to the concept that methods and properties defined by a parent class are available on all of its subclasses, e.g. an Animal class with the method &lt;strong&gt;bark&lt;/strong&gt; will have this method available on other classes which extend it.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>cschallenge</category>
      <category>computerscience</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Execute SQL Commands In Another File from the PostgreSQl psql shell in Windows</title>
      <dc:creator>John Akindipe</dc:creator>
      <pubDate>Sun, 26 May 2024 11:23:25 +0000</pubDate>
      <link>https://dev.to/johnakindipe/how-to-execute-sql-commands-in-another-file-from-the-postgresql-psql-shell-in-windows-ppa</link>
      <guid>https://dev.to/johnakindipe/how-to-execute-sql-commands-in-another-file-from-the-postgresql-psql-shell-in-windows-ppa</guid>
      <description>&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Suppose you download an sql file containing some sql instructuions (such as dummy data from mockaroo), the options you have to run these commands in postgres include copying the commands in the file over to the psql shell manually and running them. This approach is workable if the file contains only a few commands, however, say the file contains hundreds of lines of sql commands, you realize this option doesn't scale with size.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution
&lt;/h2&gt;

&lt;p&gt;Thankfully, you can execute SQL commands located in another file on your pc straight from the psql shell. The command to do this is &lt;code&gt;\i filepath to sql file&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  To get the filepath.
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Open the file in a code editor such as VSCode&lt;/li&gt;
&lt;li&gt;Right click on the file. &lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the copy path option from the dropdown menu.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx84ixrc4pm171uv25661.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx84ixrc4pm171uv25661.png" alt="Copy path"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then, open your psql shell and run this command &lt;code&gt;\i filepath to sql file&lt;/code&gt;, and it’s more than likely you’ll get the following output:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgz6wghrgo94lj4djbd9w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgz6wghrgo94lj4djbd9w.png" alt="Permission denied"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The solution to the above is quite simple really, very simple infact.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let’s troubleshoot
&lt;/h2&gt;

&lt;p&gt;It may be this file was &lt;strong&gt;downloaded&lt;/strong&gt; onto your pc and needs to have necessary permissions.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the file location&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Right-click on the file and click on properties in the drop down menu &lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvar9q33rnc8j1sed701s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvar9q33rnc8j1sed701s.png" alt="Right click on sql file"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on unblock just near the lower right edge of the &lt;em&gt;properties dialogue box&lt;/em&gt; and select the apply option (it will become clickable) &lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ns88b65hgmux8qsc1ah.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ns88b65hgmux8qsc1ah.png" alt="Unblock sql file to allow changes to the PC"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now that we’ve unblocked the file, we can run the command again in our psql shell and see what happens.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgz6wghrgo94lj4djbd9w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgz6wghrgo94lj4djbd9w.png" alt="Permission denied"&gt;&lt;/a&gt;&lt;br&gt;
Seems like we're still getting the same error as before. What could be the issue?&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution
&lt;/h2&gt;

&lt;p&gt;I did mention that the solution is simple, and it is quite simple, &lt;strong&gt;to the initiated&lt;/strong&gt;. The uninitiated might spend hours or days of debugging trying to figure out what the problem is. You may even give up at some point and just manually copy the sql commands and run them directly in the psql shell. Well, let's save ourselves any ache:&lt;/p&gt;

&lt;p&gt;The simplicity of the solution is quite interesting. All we need to do is simply change the direction of our slashes from “\” to “/” and the command works as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhtob1dolu3fwh7k2gu7m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhtob1dolu3fwh7k2gu7m.png" alt="Change slash direction from backwards to forwards"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The solution to this problem stems from how the file paths in windows differs from what the psql shell expects and all we need to do is conform to what psql wants, and that my folks is the solution.&lt;/p&gt;




&lt;h4&gt;
  
  
  This article does assume that:
&lt;/h4&gt;

&lt;p&gt;The user on the psql shell has access to the sql file we are trying to execute code from. Otherwise, all of the above might not apply and it may be necessary to get permission to access the file in the first place.&lt;/p&gt;




&lt;p&gt;Kindly share this article if you found it useful. Cheers 😊&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>commandline</category>
      <category>sql</category>
    </item>
  </channel>
</rss>
