diff --git a/databaseCryptoUpdated4.sh b/databaseCryptoUpdated4.sh new file mode 100644 index 0000000000000000000000000000000000000000..dab45692810c38ecd41ce424e4903d3cb62334db --- /dev/null +++ b/databaseCryptoUpdated4.sh @@ -0,0 +1,145 @@ +#! /usr/bin/bash + +output=$(/opt/lampp/bin/mysql -u root -e"USE cryptoTracker; SELECT * FROM crypto;" --skip-column-names 2>&1) +status=$? + +# Check the status and handle the error +if [ $status -ne 0 ]; then + echo "MySQL error: $output" +else + echo "MySQL working." + +if [ "$(curl -s -o /dev/null -w "%{http_code}" http://www.google.com/)" -eq "200" ]; then + echo "XAMPP's Apache server is connected to the internet." + +$(/opt/lampp/bin/mysql -u root -e "create database cryptoTracker; use cryptoTracker") + +#To store different types of crypto +$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker; create table crypto (cryptoId int PRIMARY KEY, name varchar(20))") +$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker; insert into crypto values (1,'Bitcoin')") + + +#To store the crypto price (value) +$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker; +create table cryptoPrice ( +id int AUTO_INCREMENT, +cryptoID int, +value float, +collected datetime, +PRIMARY KEY(id), +FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId) +)") + +#To store the 24 Hour Low +$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker; +create table lowPrice ( +id int AUTO_INCREMENT, +cryptoID int, +value float, +collected datetime, +PRIMARY KEY(id), +FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId) +)") + +#To store the 24 Hour High +$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker; +create table highPrice ( +id int AUTO_INCREMENT, +cryptoID int, +value float, +collected datetime, +PRIMARY KEY(id), +FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId) +)") + + +#To store the 24 Hour Open +$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker; +create table openPrice ( +id int AUTO_INCREMENT, +cryptoID int, +value float, +collected datetime, +PRIMARY KEY(id), +FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId) +)") + + + +#To store the Market Cap +$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker; +create table marketCap ( +id int AUTO_INCREMENT, +cryptoID int, +value float, +collected datetime, +PRIMARY KEY(id), +FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId) +)") + + +#To store the Change In Value +$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker; +create table changeInValue ( +id int AUTO_INCREMENT, +cryptoID int, +value float, +collected datetime, +PRIMARY KEY(id), +FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId) +)") + + + +#To store the Return Percentage +$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker; +create table returnPercentage ( +id int AUTO_INCREMENT, +cryptoID int, +value float, +collected datetime, +PRIMARY KEY(id), +FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId) +)") + + +#To store the Volatility +$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker; +create table volatility ( +id int AUTO_INCREMENT, +cryptoID int, +value float, +collected datetime, +PRIMARY KEY(id), +FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId) +)") + +#To store the Transaction Count +$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker; +create table transactionCount ( +id int AUTO_INCREMENT, +cryptoID int, +value float, +collected datetime, +PRIMARY KEY(id), +FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId) +)") + + +#To store the Transaction Fee +$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker; +create table transactionFee ( +id int AUTO_INCREMENT, +cryptoID int, +value float, +collected datetime, +PRIMARY KEY(id), +FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId) +)") + +else + echo "XAMPP's Apache server is not connected to the internet." +fi + +fi +