Common commands
Github
### clone repo to your local git clone https://github.com/iisc-ts-group6/capstone.git
### adds your local changes to local cloned repo
git add .
### commits changes to local git branch
git commit -m "description"
### pushes committed changes to github main
git push
### initialize a new local repo
git init
### Push a local repo to a github repo
git repo add origin https://github.com//.git
### Change branch you are working on
git branch -M main
### Same as git push, but you are specifying branch to push to
git push -u origin main
### Delete local repo
rm -r .git
Python
### executes the python scriptpython3 main.py
### runs interpreter without running the code
python3 -m py_compile main.py
Postgresql
### check if postgres is installed OR### check which instance of postgres is being referred to
which psql
### uninstall postgress
brew uninstall postgresql@15
### install version 15 of postgresql to mac
brew install postgresql@15
### connect to the default db postgres
psql -U your_user_name the_db_you_want_to_connect_to
### Common mistake here is to start with
psql -U postgres
### If the user postgres (default) is not defined you get an error connecting to socket
### Instead of using this default command, specify the user and the db
### list existing databases
\l
### start postgresql server
brew services start postgresql@15
### create a database called testdb
CREATE DATABASE testdb;
### Do not forget the semicolon
### connect to a database 'testdb' from within the psql prompt
\c testdb
### create a table with a primary key and other column(s)
CREATE TABLE table_name (
id integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
col_name varchar(100) NOT NULL CHECK (col_name <> '')
);
### show tables in the selected database
\dt
### insert multiple rows
INSERT INTO table_name (column_list)
VALUES
(value_list_1),
(value_list_2),
...
(value_list_n);
### add remove column from table
ALTER TABLE table_name DROP COLUMN column_name;