harman28 / tennis_atp

ATP Tennis Rankings, Results, and Stats
1 stars 1 forks source link

add setup script for mysql #2

Closed ritvikgautam closed 7 years ago

ritvikgautam commented 7 years ago

1

ritvikgautam commented 7 years ago

@harman28 I've made some changes.

The birth date in the players table is still as varchar. I tried making it to date, but since the csv files has a lot of empty fields for the birth date, mysql throws an error as date fields cannot be "" (it can be null). A possible solution I found was to change all empty fields in the date to null, but I don't want to touch the data now.

harman28 commented 7 years ago

@ritvikgautam Would it be possible to create another column called birth_date, and update that conditionally? i.e. fill it with a date object if date field is present, otherwise store null.

harman28 commented 7 years ago

Replace the first few lines with this:

#Set database name
if [ $# -eq 0 ]; then
   MYDATABASE="atpdatabase"
elif [ $# -eq 1 ]; then
   MYDATABASE=$1
else
  echo "Invalid parameters!";
  exit 1
fi

#Get MySQL username and password
echo -n "MySQL Username: "
read USERNAME
echo -n "Password: "
read -s PASSWORD
echo

This way password will not need to be typed in plaintext at prompt.

harman28 commented 7 years ago

@ritvikgautam Make the password change for now, and do the birth_date change separately. October is coming to an end and you probably want this merged before that.