Skip to content

gturtu21/sql_tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

| Role           | Tool               | SQL used for                             |
| -------------- | ------------------ | ---------------------------------------- |
| Analyst        | Metabase, Tableau  | Answering business questions             |
| Data Engineer  | dbt, Airflow, Bash | Cleaning & transforming data (ETL)       |
| Developer      | Flask, FastAPI     | Powering app features (e.g. orders view) |
| Data Scientist | Jupyter, Pandas    | Extracting training data for ML          |


!sudo apt update
!sudo apt install postgresql postgresql-contrib -y

!sudo service postgresql start

Check the daemon status
!sudo service postgresql status

Switch to postgres user and open the psql shell
!sudo -i -u postgres
!psql

After the previous command, the prompt should look like this:
postgres=# 


CREATE DATABASE mytestdb;
CREATE USER mytestuser WITH ENCRYPTED PASSWORD 'mypassword';
GRANT ALL PRIVILEGES ON DATABASE mytestdb TO mytestuser;

The previous command is needed to give the user privileges to create tables etc


Edit this file to allow access to database from other IPs:
!sudo nano /etc/postgresql/*/main/postgresql.conf

Look for this line and make it look like this (normally you should find localhost instead *)
listen_addresses = '*'

!sudo nano /etc/postgresql/*/main/pg_hba.conf

Add this line at the bottom
host    all             all             0.0.0.0/0               md5

!sudo service postgresql restart

After this procedure you should be aple to configure your psql connection from VSCode


For a full real-case project, you might want:

More tables (e.g., projects, performance_reviews, salaries_over_time)

Real data volume simulation (1000s of rows, not 5)

ETL scripts or Python code to connect to the database

Schema evolution: migrations, altering tables, version control

Business questions that simulate reporting needs


######
sudo -i -u postgres
createdb ecommerce_db
psql ecommerce_db

CREATE ROLE gturtu21 WITH LOGIN PASSWORD 'yourpasswordblablabla';

Create database from the file setup.sql 

psql -U gturtu2 -d ecommerce_db -f setup.sql




About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published