Skip to content

Commit bcb82da

Browse files
json_python (#59)
2 parents 3f85c3e + 570738a commit bcb82da

File tree

5 files changed

+76
-13
lines changed

5 files changed

+76
-13
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Docker Build and Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main # Trigger on pushes to the main branch
7+
8+
jobs:
9+
build-and-run:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout Repository
14+
uses: actions/checkout@v3
15+
16+
- name: Set up Docker
17+
uses: docker/setup-buildx-action@v3
18+
19+
- name: Build Docker Image
20+
run: docker build -t custom-sql-server -f docker/mssql.Dockerfile .
21+
22+
- name: Push Docker Image (Optional)
23+
env:
24+
DOCKER_USER: ${{ secrets.DOCKER_USERNAME }}
25+
DOCKER_PASS: ${{ secrets.DOCKER_PASSWORD }}
26+
run: |
27+
echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
28+
docker tag custom-sql-server username/custom-sql-server:latest
29+
docker push username/custom-sql-server:latest
30+
31+
- name: Run Docker Container
32+
run: |
33+
docker stop my-custom-sql-server || true
34+
docker rm my-custom-sql-server || true
35+
docker run -d --name my-custom-sql-server -p 1433:1433 custom-sql-server

code/python_files/json_python.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,21 @@
5353
]
5454
}
5555

56+
# Extracting maximum claim amount for each patient
57+
max_claims = {}
58+
for patient in raw_data['patients']:
59+
patient_id = patient['patient_id']
60+
max_claim = max(claim['claim_amount'] for claim in patient['claims'])
61+
max_claims[patient_id] = max_claim
5662

57-
def search_json(data, key):
58-
for i in data:
59-
print(type(i), i)
60-
print(type(data[i]), data[i])
61-
if data[i] is list:
62-
for j in data[i]:
63-
print(type(j), j)
64-
print(type(j[i]), j[i])
65-
if j[i] == key:
66-
return j
67-
else:
68-
return search_json(j, key)
63+
print(max_claims)
6964

7065

71-
print(search_json(raw_data, 'P001'))
66+
patient_input = 'P002'
67+
max_claim = None
68+
for patient in raw_data['patients']:
69+
if patient['patient_id'] == patient_input:
70+
max_claim = max(claim['claim_amount'] for claim in patient['claims'])
71+
break
72+
73+
print(f"Maximum claim amount for patient {patient_input}: {max_claim}")

docker/mssql.Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Use the official SQL Server 2022 image as the base image
2+
FROM mcr.microsoft.com/mssql/server:2022-latest
3+
4+
# Set environment variables
5+
ENV ACCEPT_EULA=Y
6+
ENV MSSQL_SA_PASSWORD=YourStrong@Passw0rd
7+
# Change to Developer/Standard/Enterprise if needed
8+
ENV MSSQL_PID=Developer
9+
10+
# Expose the SQL Server port
11+
EXPOSE 1433
12+
13+
# Start SQL Server when the container starts
14+
CMD ["/opt/mssql/bin/sqlservr"]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
inp = [1,2,3,4]
2+
sq = [16,1,9,4]
3+
4+
for i in inp:
5+
if i**2 in sq:
6+
print(i,"present")
7+
else:
8+
print(i,"not present")
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
l = [3,5,2,9,8,1]
2+
3+
l = sorted(l, reverse=True)
4+
print(l[2])

0 commit comments

Comments
 (0)