I've been meaning how to use Postgres for a while now and I've finally decided to dive into it. First step, installing Postgres from their website.
I kept all the default settings which meant it installed PostgreSQL Server, pgAdmin4, Stack Builder, and Command Line Tools. It later prompted me to set up Stack Builder, but I took a look at this tutorial and determined that I don't really need to do that right now. It also helped me figure out how to verify the installation using SQL Shell(psql). Everything looks good so far.
I followed another tutorial on Linkedin learning to create a database.
Next on the tutorial, create a virtual environment and install Psycopg2-binary in it. Apparently it's a Postgres database adapter.
And because I'm an idiot, I forgot where I saved the database. I opened up Postgres shell and used the command SHOW data_directory;
But it turns out I didn't need it anyway 😁 I created a new Python file and added the following lines of code to create a table in the db.
Ran the file. No errors. Opened up SQL shell(psql) to take a look at the table using the command \dt .
And a query to check that the columns have been built right.
Comments
Post a Comment