-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_dynamodb.py
55 lines (44 loc) · 1.75 KB
/
test_dynamodb.py
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
import boto3
# Connect to DynamoDB
dynamodb = boto3.resource("dynamodb")
# List all tables in DynamoDB
tables = list(dynamodb.tables.all())
if tables:
print("Connected to DynamoDB! Available tables:")
for table in tables:
print(table.name)
else:
print("No tables found or credentials not configured properly.")
# import json
# from FitOn.models import Exercise, MuscleGroup
# # Load the JSON data from exercise.json
# with open("exercise-list.json", "r") as file:
# exercises_data = json.load(file)
# # Loop through each exercise in the data
# for exercise_data in exercises_data["exercises"]:
# # Create or get the Exercise instance
# exercise, created = Exercise.objects.get_or_create(
# name=exercise_data["name"],
# defaults={
# "force": exercise_data.get("force"),
# "level": exercise_data.get("level"),
# "mechanic": exercise_data.get("mechanic"),
# "equipment": exercise_data.get("equipment"),
# "instructions": " ".join(exercise_data.get("instructions", [])),
# "category": exercise_data.get("category"),
# },
# )
# # Add primary muscles
# for muscle_name in exercise_data.get("primaryMuscles", []):
# muscle, _ = MuscleGroup.objects.get_or_create(name=muscle_name)
# exercise.primaryMuscles.add(muscle)
# # Add secondary muscles
# for muscle_name in exercise_data.get("secondaryMuscles", []):
# muscle, _ = MuscleGroup.objects.get_or_create(name=muscle_name)
# exercise.secondaryMuscles.add(muscle)
# # Save the exercise
# exercise.save()
# if created:
# print(f"Added new exercise: {exercise.name}")
# else:
# print(f"Updated existing exercise: {exercise.name}")