Connect With PostgreSQL using VS CODE for PRODUCTION

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
In the previous session, we learned how to connect to PostgreSQL using the Command Prompt or Terminal. Today, we will do the same thing, but using VS Code instead. So, without wasting any time, let's get started. Requirements To connect to PostgreSQL you need to have VS code installed properly on your machine. This applies to any operating system, including Windows, Linux, or Mac. Process I'm assuming that you already have VS Code installed. If so, please open it now, because we'll need to install some plugins. Here I have my VS Code opened. Now that you have VS Code open, please go to the Marketplace and search for the extension called 'SQLTools'. Make sure to write 'SQLTools' as a single word without any spaces . Here it is: Install it once you find it. I will leave the link of this Extension in the description Name: SQLTools Matheus Teixeira VS Marketplace Link: [<https://marketplace.visualstudio.com/items?itemName=mtxr.sqltools>](<https://marketplace.visualstudio.com/items?itemName=mtxr.sqltools>) After installing the extension, you should be able to see it in the extension bar on the left-hand side of your screen. It will have an icon that looks like a database. We're not done yet! Now, we need to install drivers for PostgreSQL. To do this, go back to the Marketplace and search for 'SQLTools PostgreSQL'. Both the 'SQLTools' extension and the drivers are from the publisher Matheus Teixeira. However, I'll also leave a link to the drivers in the description for your convenience. Here is the driver - The full name of the drive is SQLTools PostgreSQL/Cockroach Driver. Install it. Done! Once the driver is installed, go back to SQLTools and click on 'Add New Connection', then select 'PostgreSQL'. This will open the Connection Assistant form, which we will need to fill out. We'll be using the information from the installation string that we used in the installation video to do this. Ok let’s start - Connection name - You can name your connection whatever you want. I will name my connection as Postgres Connection Group - Leave it empty Connect String - Leave it set on “Server and Port” Server address - Since my PostgreSQL is installed on this same machine thus I will leave it set on localhost. In case you have installed your PostgreSQL on a remote server then put the ip address of that server here. Port - If you remember, while installing PostgreSQL we exposed port number 5432 for the installation. 5432 also happens to be the default port number for the PostgreSQL. We will use the same port number. Database - Here we have to put the name of the database to which we want to connect. After installation of PostgreSQL we will be provided with a default database whose name is “postgres”. This name is case sensitive so make sure to type it in all small letters Username - Similar to database name, with the installation we are provided with a default user again whose name is “postgres” all in small letters. Use Password - For the time being I will set this value to “Save as plaintext in settings”. This is not recommended. Usually we set it to “Ask to connect” on doing so you will be asked to put the password every time you will connect with the database. Password - Here put the password of the database. This is the same password you assigned while installation. In my case it was “postgres”. That’s all we have to do - Leave the remaining fields set on their default values. Now press Test connection - I got an error. This is because my Docker container for postgres isn’t running. Let me run the docker container - Here is my docker desktop app. And here is my postgres container. Let’s run it Done! Now let’s test the connection once again. Successfully connected. Next press the save connection. and then from the connection panel select the connection that you just created and right click on it and select connect. Doing so will open up a fresh SQL worksheet. In this worksheet you can write your SQL queries and run them. Let me show you how. Let’s write a query to check the current user name with which we are connected. SELECT current_user; To run this statement, press the “Run On Active Connection” button. And here is the result, which is “Postgres”. That is how we connect with PostgreSQL server using VS Code. That’s it for this tutorial. Hope you enjoyed watching it. If so then give it a thumbs up. Also subscribe to the channel and press the bell icon. Thanks for watching. This is Manish from RebellionRider.com
Info
Channel: Manish Sharma
Views: 5,706
Rating: undefined out of 5
Keywords: manish sharma, rebellion rider, how to setup postgresql, how to connect postgresql, how to connect to postgresql, postgresql with vs code, postgresql connection with vs code, how to connect with postgresql using vs code, how to connect postgresql with vs code, vs code with postgresql, postgreSQL database connection with VS Code, configuring postgreSQL in VS Code for production use, configuring postgreSQL in VS Code, how to setup postgresql with vs code, setup postgresql with vs c
Id: ByPnXAPC3W4
Channel Id: undefined
Length: 6min 25sec (385 seconds)
Published: Sun May 14 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.