-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_command.sh
More file actions
242 lines (172 loc) · 6.66 KB
/
setup_command.sh
File metadata and controls
242 lines (172 loc) · 6.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
####################################################################################
# PROJECT SETUP: requirement tools for data pipeline (Docker + SQL Server)
# Author: Ritik
# Purpose: Setup virtual environment, install dependencies, configure database
# credentials, and run the pipeline script.
####################################################################################
################################################################################
################### DOCKER INSTRALLITION AND SETUP #############################
################################################################################
#Install dependencies
sudo apt update
sudo apt install ca-certificates curl gnupg lsb-release
#Adding Docker official GPG key
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# Adding Docker repository
echo \
"deb [arch=$(dpkg --print-architecture) \
signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker Engine
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Starting and enable Docker
sudo systemctl start docker
sudo systemctl enable docker
#Fixing permission
sudo usermod -aG docker $USER
# Verify versions
docker --version
docker compose version
################################################################################
################### MSSQL INSTRALLITION AND SETUP ##############################
################################################################################
# Pulling SQL Server image
docker pull mcr.microsoft.com/mssql/server:2022-latest
# creting and running container
docker run -e "ACCEPT_EULA=Y" \
-e "MSSQL_SA_PASSWORD=Ritik@843313" \
-p 1433:1433 \
--name sqlserver \
-v sql_data:/var/opt/mssql \
-d mcr.microsoft.com/mssql/server:2022-latest
# Check running containers
docker ps
# Check all containers
docker ps -a
# Check downloaded images
docker images
# Check Docker volumes
docker volume ls
# Start container
docker start sqlserver
# Stop container
docker stop sqlserver
# Access container terminal
docker exec -it -u root sqlserver bash
# Add Microsoft repo
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
# Update
sudo apt update
# Install ODBC Driver 18
sudo ACCEPT_EULA=Y apt install msodbcsql18
# Optional but useful tools
sudo apt install unixodbc-dev
# This opens SQL CLI (sqlcmd)
docker exec -it sqlserver /opt/mssql-tools/bin/sqlcmd
-S localhost -U sa -P "Ritik@843313"
# moving data
docker cp /workspaces/dbt_learning_project/dataset sqlserver:/data/
# access SQL serve cli
docker exec -it -u root sqlserver bash
#chage file permition
chmod -R 777 /workspaces/dbt_learning_project/dataset
################################################################################
######################## DATABASE AND PYTHON SETUP #############################
################################################################################
# creating python virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate
# Install pyodbc for SQL Server connection
pip install pyodbc
# Set environment variables for database connection
nano ~/.bashrc
# Add the following lines at the end of the file
export DB_USER=sa
export DB_PASSWORD=Ritik@843313
# Load variables from ~/.bashrc
source ~/.bashrc
# Verify environment variables
echo $DB_USER
echo $DB_PASSWORD
################################################################################
##################### SENDING FILE IN DOCKER IMAGE ############################
################################################################################
# Access container terminal
docker exec -it -u root sqlserver bash
# create file in docker terminal
mkdir Dataset
# create one more file there you store you different different data
mkdir {Dataset,gym_data,ai_data}
# creating file
cd data/Dataset mkdir business_data
# Duplicate copies created inside business_data/
cp -r /data/Dataset/CRM /data/Dataset/ERP /data/Dataset/business_data/
# =========================================================
# CRM FILE PATHS
# =========================================================
# Customer Information
/data/Dataset/business_data/CRM/cust_info.csv
# Product Information
/data/Dataset/business_data/CRM/prd_info.csv
# Sales Details
/data/Dataset/business_data/CRM/sales_details.csv
# =========================================================
# ERP FILE PATHS
# =========================================================
# Customer Master
/data/Dataset/business_data/ERP/CUST_AZ12.csv
# Location Master
/data/Dataset/business_data/ERP/LOC_A101.csv
# Product Category
/data/Dataset/business_data/ERP/PX_CAT_G1V2.csv
################################################################################
########################### ADDING GIT COMMAND ################################
################################################################################
# clone repository from github
git clone https://github.com/Ritik574-coder/sqlserver-datawarehouse.git
# move into project directory
cd sqlserver-datawarehouse
# authenticate github account
git config --global user.name "Your Name"
git config --global user.email "your-email@example.com"
# create new branch
git branch warehouse_branch
# switch to branch
git switch warehouse_branch
# add single file
git add README.md
# check repository status
git status
# add all files
git add .
# commit changes
git commit -m "Implement bronze layer ETL process"
# commit with co-author
git commit -m "adding script for dashboarding and analysis all data
Co-authored-by: ritsky-project <ritsky598@gmail.com>"
# push changes to github
git push origin warehouse_branch
# view commit history
git log
################################################################################
########################### ADDING SUPERSET COMMAND ###########################
################################################################################
# Get Superset
git clone https://github.com/apache/superset
# Start the latest official release of Superset
# Enter the repository you just cloned
$ cd superset
# Set the repo to the state associated with the latest official version
$ git checkout tags/6.0.0
# Fire up Superset using Docker Compose
$ docker compose -f docker-compose-image-tag.yml up
# Log into Superset
username: admin
password: admin