diff --git a/db.sqlite3 b/db.sqlite3 index b04654d..53d894c 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/nba_data/admin.py b/nba_data/admin.py index 8c38f3f..1e06526 100644 --- a/nba_data/admin.py +++ b/nba_data/admin.py @@ -1,3 +1,6 @@ from django.contrib import admin +from .models import PlayerData # Register your models here. + +admin.site.register(PlayerData) diff --git a/nba_data/scraper.py b/nba_data/scraper.py index 00a9d14..e755c53 100644 --- a/nba_data/scraper.py +++ b/nba_data/scraper.py @@ -3,6 +3,7 @@ from bs4 import BeautifulSoup import csv import json import os +from .models import PlayerData team = input('What team? ') @@ -54,4 +55,36 @@ with open(json_output_path, 'w') as jsonfile: json.dump(data, jsonfile) -print('success') \ No newline at end of file +# save data to database + +for row in data: + player_data = PlayerData( + name=row['name'], + age=row['age'], + games=row['games'], + games_started=row['games_started'], + minutes_pg=row['minutes_pg'], + field_goals=row['field_goals'], + field_attempts=row['field_attempts'], + field_percent=row['field_percent'], + three_fg=row['three_fg'], + three_attempts=row['three_attempts'], + three_percent=row['three_percent'], + two_fg=row['two_fg'], + two_attempts=row['two_attempts'], + two_percent=row['two_percent'], + effect_fg_percent=row['effect_fg_percent'], + ft=row['ft'], + fta=row['fta'], + ft_percent=row['ft_percent'], + ORB=row['ORB'], + DRB=row['DRB'], + TRB=row['TRB'], + AST=row['AST'], + STL=row['STL'], + BLK=row['BLK'], + TOV=row['TOV'], + PF=row['PF'], + PTS=row['PTS'], + ) + player_data.save() \ No newline at end of file